Week 8 Tables + Time

Statistics 422

Tables

Setup

library(readr)
library(tidyverse)
library(knitr)
library(gt)
library(gtExtras)
library(gtsummary)
library(reactable)
options(dplyr.width = Inf, dplyr.print_max = 1e9,  width = 144)

Stock Prices

NVIDIA <- read_csv("https://raw.githubusercontent.com/lewv/S24STATS101A/main/data/NVDA.csv")
kable(glimpse(NVIDIA))
Rows: 291
Columns: 7
$ Date        <date> 2023-01-03, 2023-01-04, 2023-01-05, 2023-01-06, 2023-01-09, 2023-01-10, 2023-01-11, 2023-01-12, 2023-01-13, 2023-01-17, 2…
$ Open        <dbl> 148.51, 145.67, 144.91, 144.74, 152.84, 155.07, 158.40, 161.00, 162.78, 168.99, 176.67, 170.36, 170.11, 180.64, 188.27, 18…
$ High        <dbl> 149.96, 148.53, 145.64, 150.10, 160.56, 159.62, 160.28, 166.37, 169.22, 177.28, 178.73, 171.97, 178.56, 192.45, 194.95, 19…
$ Low         <dbl> 140.96, 142.41, 141.48, 140.34, 151.41, 154.72, 155.63, 154.92, 161.65, 168.99, 172.82, 167.31, 168.25, 178.18, 188.20, 18…
$ Close       <dbl> 143.15, 147.49, 142.65, 148.59, 156.28, 159.09, 160.01, 165.11, 168.99, 177.02, 173.77, 167.65, 178.39, 191.93, 192.65, 19…
$ `Adj Close` <dbl> 143.0798, 147.4177, 142.5800, 148.5171, 156.2034, 159.0120, 159.9315, 165.0291, 168.9071, 176.9332, 173.6848, 167.5678, 17…
$ Volume      <dbl> 40127700, 43132400, 38916800, 40504400, 50423100, 38410100, 35328500, 55140900, 44728700, 51110200, 43962400, 45293200, 56…
Date Open High Low Close Adj Close Volume
2023-01-03 148.51 149.96 140.96 143.15 143.0798 40127700
2023-01-04 145.67 148.53 142.41 147.49 147.4177 43132400
2023-01-05 144.91 145.64 141.48 142.65 142.5800 38916800
2023-01-06 144.74 150.10 140.34 148.59 148.5171 40504400
2023-01-09 152.84 160.56 151.41 156.28 156.2034 50423100
2023-01-10 155.07 159.62 154.72 159.09 159.0120 38410100
2023-01-11 158.40 160.28 155.63 160.01 159.9315 35328500
2023-01-12 161.00 166.37 154.92 165.11 165.0291 55140900
2023-01-13 162.78 169.22 161.65 168.99 168.9071 44728700
2023-01-17 168.99 177.28 168.99 177.02 176.9332 51110200
2023-01-18 176.67 178.73 172.82 173.77 173.6848 43962400
2023-01-19 170.36 171.97 167.31 167.65 167.5678 45293200
2023-01-20 170.11 178.56 168.25 178.39 178.3025 56496700
2023-01-23 180.64 192.45 178.18 191.93 191.8359 65516300
2023-01-24 188.27 194.95 188.20 192.65 192.5555 49620400
2023-01-25 189.13 193.70 185.80 193.23 193.1352 44953700
2023-01-26 197.01 201.66 192.78 198.02 197.9229 48953500
2023-01-27 194.62 206.28 194.05 203.65 203.5501 54214200
2023-01-30 199.50 201.40 191.50 191.62 191.5260 48861100
2023-01-31 191.70 196.87 189.50 195.37 195.2742 49801700
2023-02-01 196.91 211.92 196.11 209.43 209.3273 66047700
2023-02-02 210.00 219.49 207.00 217.09 216.9835 56427600
2023-02-03 210.00 217.45 207.89 211.00 210.8965 42936600
2023-02-06 208.06 215.70 207.86 210.89 210.7866 45219700
2023-02-07 213.82 222.59 211.50 221.73 221.6213 66415000
2023-02-08 223.87 228.78 220.08 222.05 221.9411 55965100
2023-02-09 226.06 230.20 221.20 223.37 223.2605 52387600
2023-02-10 216.90 220.78 208.11 212.65 212.5457 55073700
2023-02-13 215.38 220.48 209.62 217.88 217.7732 47491900
2023-02-14 215.78 230.49 213.66 229.71 229.5974 67547400
2023-02-15 225.49 228.55 221.06 227.64 227.5284 42057500
2023-02-16 221.33 225.50 219.27 220.02 219.9121 41202600
2023-02-17 216.31 217.40 209.75 213.88 213.7751 46588800
2023-02-21 210.00 214.94 206.18 206.55 206.4487 41001500
2023-02-22 207.07 211.04 204.21 207.54 207.4382 51318400
2023-02-23 234.40 238.88 230.25 236.64 236.5240 111799500
2023-02-24 232.25 234.74 229.47 232.86 232.7458 58971600
2023-02-27 236.70 238.80 234.54 235.01 234.8947 45299400
2023-02-28 233.72 238.25 232.06 232.16 232.0462 45596300
2023-03-01 231.92 232.56 225.08 226.98 226.8687 46002600
2023-03-02 224.88 233.80 224.32 233.14 233.0257 38941500
2023-03-03 233.20 239.00 231.30 238.90 238.7829 41239300
2023-03-06 238.91 242.48 234.87 235.54 235.4245 43742900
2023-03-07 236.00 241.25 232.41 232.88 232.8053 51515400
2023-03-08 234.87 242.00 234.24 241.81 241.7325 51357300
2023-03-09 241.75 244.54 233.83 234.36 234.2849 50125700
2023-03-10 234.09 236.27 227.26 229.65 229.5764 47486600
2023-03-13 227.52 232.98 222.97 229.66 229.5864 42189000
2023-03-14 234.96 242.19 234.60 240.63 240.5529 47491000
2023-03-15 237.61 242.86 233.60 242.28 242.2023 52448600
2023-03-16 240.27 255.88 238.94 255.41 255.3281 58325300
2023-03-17 259.82 263.99 256.68 257.25 257.1675 84854700
2023-03-20 256.15 260.24 251.30 259.00 258.9170 43274700
2023-03-21 261.80 263.92 253.81 261.99 261.9060 54740800
2023-03-22 264.25 275.89 262.37 264.68 264.5952 79729500
2023-03-23 271.15 274.99 266.90 271.91 271.8228 56488900
2023-03-24 270.31 271.67 263.55 267.79 267.7041 45492000
2023-03-27 268.37 270.00 263.65 265.31 265.2249 36102600
2023-03-28 264.47 265.13 258.50 264.10 264.0153 35610400
2023-03-29 268.25 270.78 265.97 269.84 269.7535 39369400
2023-03-30 272.29 274.99 271.02 273.83 273.7422 36451600
2023-03-31 271.40 278.34 271.05 277.77 277.6809 43393300
2023-04-03 275.09 280.00 273.36 279.65 279.5603 39871600
2023-04-04 279.66 280.00 273.07 274.53 274.4420 36859200
2023-04-05 268.29 269.98 263.95 268.81 268.7238 51501500
2023-04-06 265.84 270.80 264.27 270.37 270.2833 39765400
2023-04-10 268.23 276.21 266.69 275.79 275.7016 39527900
2023-04-11 277.24 277.90 271.26 271.69 271.6029 31437800
2023-04-12 273.70 274.68 264.48 264.95 264.8651 44625900
2023-04-13 267.34 268.87 263.29 264.63 264.5452 35361500
2023-04-14 265.04 268.83 262.20 267.58 267.4942 39566000
2023-04-17 265.65 270.06 264.33 270.02 269.9334 32147100
2023-04-18 275.33 281.10 273.57 276.67 276.5813 60481200
2023-04-19 273.61 280.00 272.32 279.31 279.2204 35866000
2023-04-20 276.71 280.30 270.00 271.04 270.9531 42771300
2023-04-21 269.52 271.83 267.22 271.19 271.1031 34510300
2023-04-24 270.13 273.66 266.71 270.42 270.3333 33928200
2023-04-25 270.78 272.47 262.25 262.41 262.3259 37852700
2023-04-26 270.02 273.30 267.05 269.56 269.4735 40633700
2023-04-27 273.63 274.95 266.25 272.26 272.1727 37716100
2023-04-28 272.25 277.58 270.71 277.49 277.4010 29168700
2023-05-01 278.40 290.58 277.80 289.10 289.0073 57032900
2023-05-02 286.80 288.36 280.83 282.10 282.0096 40273000
2023-05-03 278.40 283.67 274.72 278.02 277.9309 38338700
2023-05-04 276.51 278.59 272.40 275.62 275.5316 32185000
2023-05-05 278.26 287.55 277.31 286.80 286.7080 36101400
2023-05-08 285.22 292.20 283.50 291.51 291.4165 34497900
2023-05-09 288.99 289.73 284.50 285.71 285.6184 31486900
2023-05-10 290.05 291.13 284.61 288.85 288.7574 36935000
2023-05-11 288.96 289.50 282.46 285.78 285.6884 32214900
2023-05-12 285.29 287.80 280.46 283.40 283.3091 27402700
2023-05-15 285.08 289.69 281.52 289.53 289.4372 29392600
2023-05-16 288.41 298.70 288.32 292.13 292.0363 44940500
2023-05-17 295.84 301.99 294.30 301.78 301.6832 43253500
2023-05-18 304.10 318.28 303.20 316.78 316.6784 74872500
2023-05-19 315.36 315.80 309.16 312.64 312.5398 47312400
2023-05-22 309.01 315.20 306.80 311.76 311.6600 37200000
2023-05-23 310.00 312.88 306.31 306.88 306.7816 35625300
2023-05-24 302.10 306.07 298.06 305.38 305.2821 72141900
2023-05-25 385.23 394.80 366.35 379.80 379.6782 154391100
2023-05-26 378.90 391.70 375.50 389.46 389.3351 71439700
2023-05-30 405.95 419.38 399.49 401.11 400.9814 92340100
2023-05-31 394.88 402.95 378.22 378.34 378.2187 100258000
2023-06-01 384.89 400.50 383.40 397.70 397.5725 63587300
2023-06-02 400.97 405.00 390.58 393.27 393.1439 48165500
2023-06-05 389.09 395.65 387.07 391.71 391.5844 39609400
2023-06-06 388.30 391.60 381.48 386.54 386.4161 38872900
2023-06-07 389.15 394.99 373.56 374.75 374.6686 51199800
2023-06-08 377.24 388.64 375.05 385.10 385.0164 41777200
2023-06-09 390.37 397.11 385.67 387.70 387.6158 42722000
2023-06-12 392.00 395.30 386.18 394.82 394.7343 38870100
2023-06-13 401.86 411.01 397.40 410.22 410.1309 61320800
2023-06-14 408.24 430.00 405.52 429.97 429.8766 74046500
2023-06-15 426.02 432.89 421.47 426.53 426.4373 56862200
2023-06-16 434.50 437.21 426.61 426.92 426.8273 65475500
2023-06-20 429.98 439.90 426.74 438.08 437.9849 45115300
2023-06-21 435.01 436.15 420.80 430.45 430.3565 55160300
2023-06-22 422.53 434.26 422.34 430.25 430.1566 41773700
2023-06-23 424.64 428.09 420.15 422.09 421.9983 35632300
2023-06-26 424.61 427.64 401.00 406.32 406.2318 59432200
2023-06-27 407.99 419.40 404.48 418.76 418.6691 46217500
2023-06-28 406.60 418.45 405.18 411.17 411.0807 58263900
2023-06-29 415.58 416.00 406.00 408.22 408.1313 38051400
2023-06-30 416.80 425.50 415.01 423.02 422.9281 50053400
2023-07-03 425.17 428.98 422.02 424.13 424.0379 19820900
2023-07-05 421.35 431.77 420.85 423.17 423.0781 32361800
2023-07-06 418.44 421.79 413.46 421.03 420.9386 30358200
2023-07-07 423.22 432.14 421.80 425.03 424.9377 35525300
2023-07-10 426.57 428.11 416.49 421.80 421.7084 35390800
2023-07-11 424.81 427.58 420.67 424.05 423.9579 29824400
2023-07-12 430.33 439.35 427.77 439.02 438.9246 48127700
2023-07-13 445.18 461.55 444.92 459.77 459.6701 47820400
2023-07-14 465.83 480.88 450.60 454.69 454.5912 77066400
2023-07-17 462.89 464.96 452.62 464.61 464.5091 51048800
2023-07-18 467.01 478.96 457.34 474.94 474.8369 57019000
2023-07-19 474.64 478.18 467.42 470.77 470.6677 42750200
2023-07-20 465.07 470.87 450.62 455.20 455.1011 53786500
2023-07-21 457.88 458.66 441.00 443.09 442.9938 96283200
2023-07-24 447.31 451.09 440.40 446.12 446.0231 38251600
2023-07-25 449.41 461.83 449.23 456.79 456.6908 34808100
2023-07-26 460.21 460.53 446.30 454.52 454.4213 36423700
2023-07-27 465.19 473.95 457.50 459.00 458.9003 45597600
2023-07-28 466.68 470.27 463.81 467.50 467.3985 33119400
2023-07-31 467.54 471.30 465.06 467.29 467.1885 25105500
2023-08-01 464.60 469.00 460.27 465.07 464.9690 23785800
2023-08-02 458.31 458.40 433.87 442.69 442.5939 53014200
2023-08-03 438.00 451.18 438.00 445.15 445.0533 32417600
2023-08-04 449.85 456.42 443.93 446.80 446.7029 36225800
2023-08-07 451.11 455.40 445.63 454.17 454.0714 32215400
2023-08-08 448.53 452.42 440.56 446.64 446.5430 35384300
2023-08-09 442.74 443.12 421.34 425.54 425.4476 58644900
2023-08-10 421.60 435.74 418.35 423.88 423.7880 49270500
2023-08-11 417.51 420.18 406.39 408.55 408.4612 53200900
2023-08-14 404.86 438.00 403.11 437.53 437.4350 69028600
2023-08-15 445.60 452.68 437.10 439.40 439.3046 67651200
2023-08-16 445.20 446.75 434.06 434.86 434.7655 52745100
2023-08-17 439.70 440.62 430.01 433.44 433.3459 45239500
2023-08-18 426.35 435.78 416.60 432.99 432.8960 58262200
2023-08-21 444.94 470.65 442.22 469.67 469.5680 69257300
2023-08-22 481.35 481.87 453.33 456.68 456.5808 75720700
2023-08-23 458.66 472.00 452.08 471.16 471.0577 77904600
2023-08-24 502.16 502.66 471.59 471.63 471.5276 115604400
2023-08-25 470.12 478.05 450.24 460.18 460.0800 92534100
2023-08-28 464.82 469.80 448.88 468.35 468.2483 68519200
2023-08-29 466.66 490.81 463.91 487.84 487.7340 70139700
2023-08-30 490.44 499.27 484.25 492.64 492.5330 73520600
2023-08-31 493.80 497.44 489.58 493.55 493.4428 52857000
2023-09-01 497.62 498.00 481.42 485.09 484.9846 46319100
2023-09-05 482.23 488.51 478.60 485.48 485.3746 38265300
2023-09-06 484.41 485.49 465.80 470.61 470.5465 46867000
2023-09-07 455.25 463.44 451.52 462.41 462.3477 43333000
2023-09-08 459.42 466.06 452.71 455.72 455.6586 47306900
2023-09-11 461.48 461.63 443.12 451.78 451.7191 47396600
2023-09-12 447.38 456.73 445.31 448.70 448.6395 34925600
2023-09-13 446.00 459.30 445.03 454.85 454.7887 39835500
2023-09-14 459.50 459.87 451.31 455.81 455.7485 37009700
2023-09-15 453.41 455.99 438.08 439.00 438.9408 50571300
2023-09-18 427.48 442.42 420.00 439.66 439.6007 50027100
2023-09-19 438.33 439.66 430.02 435.20 435.1413 37306400
2023-09-20 436.00 439.03 422.23 422.39 422.3331 36710800
2023-09-21 415.83 421.00 409.80 410.17 410.1147 44893000
2023-09-22 415.72 421.15 412.31 416.10 416.0439 47923600
2023-09-25 415.91 425.36 411.77 422.22 422.1631 41909100
2023-09-26 420.01 428.20 416.55 419.11 419.0535 40228200
2023-09-27 423.30 428.72 416.29 424.68 424.6227 44493500
2023-09-28 424.60 434.46 421.15 430.89 430.8319 42466300
2023-09-29 438.27 441.44 433.07 434.99 434.9313 39722100
2023-10-02 440.30 451.75 438.61 447.82 447.7596 43329800
2023-10-03 448.08 451.30 432.46 435.17 435.1113 47085000
2023-10-04 437.42 441.43 432.92 440.41 440.3506 36182100
2023-10-05 440.50 449.00 438.88 446.88 446.8198 39348300
2023-10-06 441.93 457.89 440.26 457.62 457.5583 43339700
2023-10-09 448.42 456.05 443.68 452.73 452.6690 40967500
2023-10-10 453.10 462.59 450.88 457.98 457.9183 36858200
2023-10-11 461.96 468.59 460.50 468.06 467.9969 37813700
2023-10-12 467.77 476.09 463.30 469.45 469.3867 48132500
2023-10-13 469.60 471.16 452.80 454.61 454.5487 47411500
2023-10-16 450.63 462.25 449.12 460.95 460.8879 37509900
2023-10-17 440.00 447.54 424.80 439.38 439.3208 81233300
2023-10-18 425.91 432.19 418.25 421.96 421.9031 62729400
2023-10-19 428.11 432.97 418.82 421.01 420.9532 50123300
2023-10-20 418.90 424.70 410.78 413.87 413.8142 47638100
2023-10-23 412.29 432.48 409.45 429.75 429.6920 47853000
2023-10-24 430.77 436.97 426.91 436.63 436.5711 40146300
2023-10-25 433.98 436.50 415.55 417.79 417.7337 39837900
2023-10-26 418.53 422.56 398.80 403.26 403.2056 54100100
2023-10-27 411.30 412.06 400.15 405.00 404.9454 41678400
2023-10-30 410.87 417.66 404.81 411.61 411.5545 38802800
2023-10-31 404.50 408.79 392.30 407.80 407.7450 51796900
2023-11-01 408.84 423.81 408.69 423.25 423.1929 43759300
2023-11-02 433.28 438.84 428.94 435.06 435.0013 40917200
2023-11-03 440.20 453.09 437.23 450.05 449.9893 42385500
2023-11-06 452.85 459.35 448.99 457.51 457.4483 40073300
2023-11-07 457.19 462.18 451.58 459.55 459.4880 34316500
2023-11-08 461.00 468.67 459.68 465.74 465.6772 34671900
2023-11-09 474.67 482.30 467.50 469.50 469.4367 54049600
2023-11-10 475.00 484.72 472.83 483.35 483.2849 42124500
2023-11-13 483.20 491.16 480.99 486.20 486.1345 38413600
2023-11-14 496.80 498.34 490.40 496.56 496.4930 41695400
2023-11-15 499.35 499.60 482.00 488.88 488.8141 47549700
2023-11-16 486.79 495.25 483.30 494.80 494.7333 33975600
2023-11-17 495.24 497.17 490.07 492.98 492.9135 32520500
2023-11-20 493.12 505.48 491.81 504.09 504.0220 41412000
2023-11-21 501.26 505.17 492.22 499.44 499.3727 56574700
2023-11-22 498.52 503.35 476.90 487.16 487.0943 89942000
2023-11-24 484.70 489.21 477.45 477.76 477.6956 29464500
2023-11-27 478.00 485.30 476.52 482.42 482.3550 39566200
2023-11-28 482.36 483.23 474.73 478.21 478.1455 40149100
2023-11-29 483.79 487.62 478.60 481.40 481.3351 38200500
2023-11-30 480.24 481.10 464.22 467.70 467.6370 52624700
2023-12-01 465.25 472.00 461.87 467.65 467.5869 36880900
2023-12-04 460.77 460.77 450.10 455.10 455.0387 43754300
2023-12-05 454.66 466.00 452.71 465.66 465.6382 37171800
2023-12-06 472.15 473.87 454.12 455.03 455.0087 38059000
2023-12-07 457.00 466.29 456.04 465.96 465.9381 35082300
2023-12-08 465.95 477.41 465.50 475.06 475.0377 35880300
2023-12-11 474.91 475.31 458.30 466.27 466.2481 50972800
2023-12-12 460.46 476.66 460.46 476.57 476.5476 37238700
2023-12-13 476.29 485.94 476.08 480.88 480.8575 44779200
2023-12-14 483.90 486.70 474.22 483.50 483.4773 39123200
2023-12-15 481.94 494.04 481.20 488.90 488.8771 47947800
2023-12-18 494.00 504.33 491.50 500.77 500.7465 41258700
2023-12-19 494.24 497.00 488.95 496.04 496.0168 46444400
2023-12-20 496.55 499.99 480.98 481.11 481.0874 39789400
2023-12-21 488.11 490.95 484.19 489.90 489.8770 30042500
2023-12-22 491.95 493.83 484.67 488.30 488.2771 25213900
2023-12-26 489.68 496.00 489.60 492.79 492.7669 24420000
2023-12-27 495.11 496.80 490.85 494.17 494.1468 23364800
2023-12-28 496.43 498.84 494.12 495.22 495.1968 24658700
2023-12-29 498.13 499.97 487.51 495.22 495.1968 38869000
2024-01-02 492.44 492.95 475.95 481.68 481.6574 41125400
2024-01-03 474.85 481.84 473.20 475.69 475.6677 32089600
2024-01-04 477.67 485.00 475.08 479.98 479.9575 30653500
2024-01-05 484.62 495.47 483.06 490.97 490.9470 41456800
2024-01-08 495.12 522.75 494.79 522.53 522.5055 64251000
2024-01-09 524.01 543.25 516.90 531.40 531.3751 77310000
2024-01-10 536.16 546.00 534.89 543.50 543.4745 53379600
2024-01-11 549.99 553.46 535.60 548.22 548.1943 59675900
2024-01-12 546.20 549.70 543.30 547.10 547.0743 35247900
2024-01-16 550.18 568.35 549.00 563.82 563.7936 44958000
2024-01-17 563.47 564.71 547.40 560.53 560.5037 47439400
2024-01-18 572.60 576.00 561.07 571.07 571.0432 49165000
2024-01-19 579.89 595.00 572.25 594.91 594.8821 54210300
2024-01-22 600.49 603.31 590.70 596.54 596.5120 45295500
2024-01-23 595.70 599.10 585.85 598.73 598.7019 29465400
2024-01-24 603.04 628.49 599.38 613.62 613.5912 56027100
2024-01-25 623.50 627.19 608.50 616.17 616.1411 48277700
2024-01-26 609.60 617.83 605.73 610.31 610.2814 39030900
2024-01-29 612.32 624.89 609.07 624.65 624.6207 34873300
2024-01-30 629.00 634.93 622.60 627.74 627.7106 41073500
2024-01-31 614.40 622.69 607.00 615.27 615.2411 45379500
2024-02-01 621.00 631.91 616.50 630.27 630.2405 36914600
2024-02-02 639.74 666.00 636.90 661.60 661.5690 47578000
2024-02-05 682.25 694.97 672.05 693.32 693.2875 68007800
2024-02-06 696.30 697.54 663.00 682.23 682.1980 68311100
2024-02-07 683.19 702.20 676.00 700.99 700.9571 49557500
2024-02-08 700.74 707.94 694.55 696.41 696.3773 41442200
2024-02-09 705.33 721.85 702.12 721.33 721.2962 43663700
2024-02-12 726.00 746.11 712.50 722.48 722.4461 61371000
2024-02-13 704.00 734.50 696.20 721.28 721.2462 60258000
2024-02-14 732.02 742.36 719.38 739.00 738.9653 50491700
2024-02-15 738.69 739.75 724.00 726.58 726.5460 42012200
2024-02-16 741.00 744.02 725.01 726.13 726.0959 49391800
2024-02-20 719.47 719.56 677.34 694.52 694.4874 70483300
2024-02-21 680.06 688.88 662.48 674.72 674.6883 69029800
2024-02-22 750.25 785.75 742.20 785.38 785.3431 86510000
2024-02-23 807.90 823.94 775.70 788.17 788.1330 82938800
2024-02-26 797.00 806.46 785.05 790.92 790.8829 50397300
2024-02-27 793.81 794.80 771.62 787.01 786.9731 39170500
2024-02-28 776.20 789.33 771.25 776.63 776.5936 39311000
2024-02-29 790.94 799.90 783.50 791.12 791.0829 50728900

Standard knitr table

This is standard if you use Quarto (highly recommended) or R Markdown to produce reports or slides. Just wrap kable() around objects that are more or less rectangular:

kable(NVIDIA) 
Date Open High Low Close Adj Close Volume
2023-01-03 148.51 149.96 140.96 143.15 143.0798 40127700
2023-01-04 145.67 148.53 142.41 147.49 147.4177 43132400
2023-01-05 144.91 145.64 141.48 142.65 142.5800 38916800
2023-01-06 144.74 150.10 140.34 148.59 148.5171 40504400
2023-01-09 152.84 160.56 151.41 156.28 156.2034 50423100
2023-01-10 155.07 159.62 154.72 159.09 159.0120 38410100
2023-01-11 158.40 160.28 155.63 160.01 159.9315 35328500
2023-01-12 161.00 166.37 154.92 165.11 165.0291 55140900
2023-01-13 162.78 169.22 161.65 168.99 168.9071 44728700
2023-01-17 168.99 177.28 168.99 177.02 176.9332 51110200
2023-01-18 176.67 178.73 172.82 173.77 173.6848 43962400
2023-01-19 170.36 171.97 167.31 167.65 167.5678 45293200
2023-01-20 170.11 178.56 168.25 178.39 178.3025 56496700
2023-01-23 180.64 192.45 178.18 191.93 191.8359 65516300
2023-01-24 188.27 194.95 188.20 192.65 192.5555 49620400
2023-01-25 189.13 193.70 185.80 193.23 193.1352 44953700
2023-01-26 197.01 201.66 192.78 198.02 197.9229 48953500
2023-01-27 194.62 206.28 194.05 203.65 203.5501 54214200
2023-01-30 199.50 201.40 191.50 191.62 191.5260 48861100
2023-01-31 191.70 196.87 189.50 195.37 195.2742 49801700
2023-02-01 196.91 211.92 196.11 209.43 209.3273 66047700
2023-02-02 210.00 219.49 207.00 217.09 216.9835 56427600
2023-02-03 210.00 217.45 207.89 211.00 210.8965 42936600
2023-02-06 208.06 215.70 207.86 210.89 210.7866 45219700
2023-02-07 213.82 222.59 211.50 221.73 221.6213 66415000
2023-02-08 223.87 228.78 220.08 222.05 221.9411 55965100
2023-02-09 226.06 230.20 221.20 223.37 223.2605 52387600
2023-02-10 216.90 220.78 208.11 212.65 212.5457 55073700
2023-02-13 215.38 220.48 209.62 217.88 217.7732 47491900
2023-02-14 215.78 230.49 213.66 229.71 229.5974 67547400
2023-02-15 225.49 228.55 221.06 227.64 227.5284 42057500
2023-02-16 221.33 225.50 219.27 220.02 219.9121 41202600
2023-02-17 216.31 217.40 209.75 213.88 213.7751 46588800
2023-02-21 210.00 214.94 206.18 206.55 206.4487 41001500
2023-02-22 207.07 211.04 204.21 207.54 207.4382 51318400
2023-02-23 234.40 238.88 230.25 236.64 236.5240 111799500
2023-02-24 232.25 234.74 229.47 232.86 232.7458 58971600
2023-02-27 236.70 238.80 234.54 235.01 234.8947 45299400
2023-02-28 233.72 238.25 232.06 232.16 232.0462 45596300
2023-03-01 231.92 232.56 225.08 226.98 226.8687 46002600
2023-03-02 224.88 233.80 224.32 233.14 233.0257 38941500
2023-03-03 233.20 239.00 231.30 238.90 238.7829 41239300
2023-03-06 238.91 242.48 234.87 235.54 235.4245 43742900
2023-03-07 236.00 241.25 232.41 232.88 232.8053 51515400
2023-03-08 234.87 242.00 234.24 241.81 241.7325 51357300
2023-03-09 241.75 244.54 233.83 234.36 234.2849 50125700
2023-03-10 234.09 236.27 227.26 229.65 229.5764 47486600
2023-03-13 227.52 232.98 222.97 229.66 229.5864 42189000
2023-03-14 234.96 242.19 234.60 240.63 240.5529 47491000
2023-03-15 237.61 242.86 233.60 242.28 242.2023 52448600
2023-03-16 240.27 255.88 238.94 255.41 255.3281 58325300
2023-03-17 259.82 263.99 256.68 257.25 257.1675 84854700
2023-03-20 256.15 260.24 251.30 259.00 258.9170 43274700
2023-03-21 261.80 263.92 253.81 261.99 261.9060 54740800
2023-03-22 264.25 275.89 262.37 264.68 264.5952 79729500
2023-03-23 271.15 274.99 266.90 271.91 271.8228 56488900
2023-03-24 270.31 271.67 263.55 267.79 267.7041 45492000
2023-03-27 268.37 270.00 263.65 265.31 265.2249 36102600
2023-03-28 264.47 265.13 258.50 264.10 264.0153 35610400
2023-03-29 268.25 270.78 265.97 269.84 269.7535 39369400
2023-03-30 272.29 274.99 271.02 273.83 273.7422 36451600
2023-03-31 271.40 278.34 271.05 277.77 277.6809 43393300
2023-04-03 275.09 280.00 273.36 279.65 279.5603 39871600
2023-04-04 279.66 280.00 273.07 274.53 274.4420 36859200
2023-04-05 268.29 269.98 263.95 268.81 268.7238 51501500
2023-04-06 265.84 270.80 264.27 270.37 270.2833 39765400
2023-04-10 268.23 276.21 266.69 275.79 275.7016 39527900
2023-04-11 277.24 277.90 271.26 271.69 271.6029 31437800
2023-04-12 273.70 274.68 264.48 264.95 264.8651 44625900
2023-04-13 267.34 268.87 263.29 264.63 264.5452 35361500
2023-04-14 265.04 268.83 262.20 267.58 267.4942 39566000
2023-04-17 265.65 270.06 264.33 270.02 269.9334 32147100
2023-04-18 275.33 281.10 273.57 276.67 276.5813 60481200
2023-04-19 273.61 280.00 272.32 279.31 279.2204 35866000
2023-04-20 276.71 280.30 270.00 271.04 270.9531 42771300
2023-04-21 269.52 271.83 267.22 271.19 271.1031 34510300
2023-04-24 270.13 273.66 266.71 270.42 270.3333 33928200
2023-04-25 270.78 272.47 262.25 262.41 262.3259 37852700
2023-04-26 270.02 273.30 267.05 269.56 269.4735 40633700
2023-04-27 273.63 274.95 266.25 272.26 272.1727 37716100
2023-04-28 272.25 277.58 270.71 277.49 277.4010 29168700
2023-05-01 278.40 290.58 277.80 289.10 289.0073 57032900
2023-05-02 286.80 288.36 280.83 282.10 282.0096 40273000
2023-05-03 278.40 283.67 274.72 278.02 277.9309 38338700
2023-05-04 276.51 278.59 272.40 275.62 275.5316 32185000
2023-05-05 278.26 287.55 277.31 286.80 286.7080 36101400
2023-05-08 285.22 292.20 283.50 291.51 291.4165 34497900
2023-05-09 288.99 289.73 284.50 285.71 285.6184 31486900
2023-05-10 290.05 291.13 284.61 288.85 288.7574 36935000
2023-05-11 288.96 289.50 282.46 285.78 285.6884 32214900
2023-05-12 285.29 287.80 280.46 283.40 283.3091 27402700
2023-05-15 285.08 289.69 281.52 289.53 289.4372 29392600
2023-05-16 288.41 298.70 288.32 292.13 292.0363 44940500
2023-05-17 295.84 301.99 294.30 301.78 301.6832 43253500
2023-05-18 304.10 318.28 303.20 316.78 316.6784 74872500
2023-05-19 315.36 315.80 309.16 312.64 312.5398 47312400
2023-05-22 309.01 315.20 306.80 311.76 311.6600 37200000
2023-05-23 310.00 312.88 306.31 306.88 306.7816 35625300
2023-05-24 302.10 306.07 298.06 305.38 305.2821 72141900
2023-05-25 385.23 394.80 366.35 379.80 379.6782 154391100
2023-05-26 378.90 391.70 375.50 389.46 389.3351 71439700
2023-05-30 405.95 419.38 399.49 401.11 400.9814 92340100
2023-05-31 394.88 402.95 378.22 378.34 378.2187 100258000
2023-06-01 384.89 400.50 383.40 397.70 397.5725 63587300
2023-06-02 400.97 405.00 390.58 393.27 393.1439 48165500
2023-06-05 389.09 395.65 387.07 391.71 391.5844 39609400
2023-06-06 388.30 391.60 381.48 386.54 386.4161 38872900
2023-06-07 389.15 394.99 373.56 374.75 374.6686 51199800
2023-06-08 377.24 388.64 375.05 385.10 385.0164 41777200
2023-06-09 390.37 397.11 385.67 387.70 387.6158 42722000
2023-06-12 392.00 395.30 386.18 394.82 394.7343 38870100
2023-06-13 401.86 411.01 397.40 410.22 410.1309 61320800
2023-06-14 408.24 430.00 405.52 429.97 429.8766 74046500
2023-06-15 426.02 432.89 421.47 426.53 426.4373 56862200
2023-06-16 434.50 437.21 426.61 426.92 426.8273 65475500
2023-06-20 429.98 439.90 426.74 438.08 437.9849 45115300
2023-06-21 435.01 436.15 420.80 430.45 430.3565 55160300
2023-06-22 422.53 434.26 422.34 430.25 430.1566 41773700
2023-06-23 424.64 428.09 420.15 422.09 421.9983 35632300
2023-06-26 424.61 427.64 401.00 406.32 406.2318 59432200
2023-06-27 407.99 419.40 404.48 418.76 418.6691 46217500
2023-06-28 406.60 418.45 405.18 411.17 411.0807 58263900
2023-06-29 415.58 416.00 406.00 408.22 408.1313 38051400
2023-06-30 416.80 425.50 415.01 423.02 422.9281 50053400
2023-07-03 425.17 428.98 422.02 424.13 424.0379 19820900
2023-07-05 421.35 431.77 420.85 423.17 423.0781 32361800
2023-07-06 418.44 421.79 413.46 421.03 420.9386 30358200
2023-07-07 423.22 432.14 421.80 425.03 424.9377 35525300
2023-07-10 426.57 428.11 416.49 421.80 421.7084 35390800
2023-07-11 424.81 427.58 420.67 424.05 423.9579 29824400
2023-07-12 430.33 439.35 427.77 439.02 438.9246 48127700
2023-07-13 445.18 461.55 444.92 459.77 459.6701 47820400
2023-07-14 465.83 480.88 450.60 454.69 454.5912 77066400
2023-07-17 462.89 464.96 452.62 464.61 464.5091 51048800
2023-07-18 467.01 478.96 457.34 474.94 474.8369 57019000
2023-07-19 474.64 478.18 467.42 470.77 470.6677 42750200
2023-07-20 465.07 470.87 450.62 455.20 455.1011 53786500
2023-07-21 457.88 458.66 441.00 443.09 442.9938 96283200
2023-07-24 447.31 451.09 440.40 446.12 446.0231 38251600
2023-07-25 449.41 461.83 449.23 456.79 456.6908 34808100
2023-07-26 460.21 460.53 446.30 454.52 454.4213 36423700
2023-07-27 465.19 473.95 457.50 459.00 458.9003 45597600
2023-07-28 466.68 470.27 463.81 467.50 467.3985 33119400
2023-07-31 467.54 471.30 465.06 467.29 467.1885 25105500
2023-08-01 464.60 469.00 460.27 465.07 464.9690 23785800
2023-08-02 458.31 458.40 433.87 442.69 442.5939 53014200
2023-08-03 438.00 451.18 438.00 445.15 445.0533 32417600
2023-08-04 449.85 456.42 443.93 446.80 446.7029 36225800
2023-08-07 451.11 455.40 445.63 454.17 454.0714 32215400
2023-08-08 448.53 452.42 440.56 446.64 446.5430 35384300
2023-08-09 442.74 443.12 421.34 425.54 425.4476 58644900
2023-08-10 421.60 435.74 418.35 423.88 423.7880 49270500
2023-08-11 417.51 420.18 406.39 408.55 408.4612 53200900
2023-08-14 404.86 438.00 403.11 437.53 437.4350 69028600
2023-08-15 445.60 452.68 437.10 439.40 439.3046 67651200
2023-08-16 445.20 446.75 434.06 434.86 434.7655 52745100
2023-08-17 439.70 440.62 430.01 433.44 433.3459 45239500
2023-08-18 426.35 435.78 416.60 432.99 432.8960 58262200
2023-08-21 444.94 470.65 442.22 469.67 469.5680 69257300
2023-08-22 481.35 481.87 453.33 456.68 456.5808 75720700
2023-08-23 458.66 472.00 452.08 471.16 471.0577 77904600
2023-08-24 502.16 502.66 471.59 471.63 471.5276 115604400
2023-08-25 470.12 478.05 450.24 460.18 460.0800 92534100
2023-08-28 464.82 469.80 448.88 468.35 468.2483 68519200
2023-08-29 466.66 490.81 463.91 487.84 487.7340 70139700
2023-08-30 490.44 499.27 484.25 492.64 492.5330 73520600
2023-08-31 493.80 497.44 489.58 493.55 493.4428 52857000
2023-09-01 497.62 498.00 481.42 485.09 484.9846 46319100
2023-09-05 482.23 488.51 478.60 485.48 485.3746 38265300
2023-09-06 484.41 485.49 465.80 470.61 470.5465 46867000
2023-09-07 455.25 463.44 451.52 462.41 462.3477 43333000
2023-09-08 459.42 466.06 452.71 455.72 455.6586 47306900
2023-09-11 461.48 461.63 443.12 451.78 451.7191 47396600
2023-09-12 447.38 456.73 445.31 448.70 448.6395 34925600
2023-09-13 446.00 459.30 445.03 454.85 454.7887 39835500
2023-09-14 459.50 459.87 451.31 455.81 455.7485 37009700
2023-09-15 453.41 455.99 438.08 439.00 438.9408 50571300
2023-09-18 427.48 442.42 420.00 439.66 439.6007 50027100
2023-09-19 438.33 439.66 430.02 435.20 435.1413 37306400
2023-09-20 436.00 439.03 422.23 422.39 422.3331 36710800
2023-09-21 415.83 421.00 409.80 410.17 410.1147 44893000
2023-09-22 415.72 421.15 412.31 416.10 416.0439 47923600
2023-09-25 415.91 425.36 411.77 422.22 422.1631 41909100
2023-09-26 420.01 428.20 416.55 419.11 419.0535 40228200
2023-09-27 423.30 428.72 416.29 424.68 424.6227 44493500
2023-09-28 424.60 434.46 421.15 430.89 430.8319 42466300
2023-09-29 438.27 441.44 433.07 434.99 434.9313 39722100
2023-10-02 440.30 451.75 438.61 447.82 447.7596 43329800
2023-10-03 448.08 451.30 432.46 435.17 435.1113 47085000
2023-10-04 437.42 441.43 432.92 440.41 440.3506 36182100
2023-10-05 440.50 449.00 438.88 446.88 446.8198 39348300
2023-10-06 441.93 457.89 440.26 457.62 457.5583 43339700
2023-10-09 448.42 456.05 443.68 452.73 452.6690 40967500
2023-10-10 453.10 462.59 450.88 457.98 457.9183 36858200
2023-10-11 461.96 468.59 460.50 468.06 467.9969 37813700
2023-10-12 467.77 476.09 463.30 469.45 469.3867 48132500
2023-10-13 469.60 471.16 452.80 454.61 454.5487 47411500
2023-10-16 450.63 462.25 449.12 460.95 460.8879 37509900
2023-10-17 440.00 447.54 424.80 439.38 439.3208 81233300
2023-10-18 425.91 432.19 418.25 421.96 421.9031 62729400
2023-10-19 428.11 432.97 418.82 421.01 420.9532 50123300
2023-10-20 418.90 424.70 410.78 413.87 413.8142 47638100
2023-10-23 412.29 432.48 409.45 429.75 429.6920 47853000
2023-10-24 430.77 436.97 426.91 436.63 436.5711 40146300
2023-10-25 433.98 436.50 415.55 417.79 417.7337 39837900
2023-10-26 418.53 422.56 398.80 403.26 403.2056 54100100
2023-10-27 411.30 412.06 400.15 405.00 404.9454 41678400
2023-10-30 410.87 417.66 404.81 411.61 411.5545 38802800
2023-10-31 404.50 408.79 392.30 407.80 407.7450 51796900
2023-11-01 408.84 423.81 408.69 423.25 423.1929 43759300
2023-11-02 433.28 438.84 428.94 435.06 435.0013 40917200
2023-11-03 440.20 453.09 437.23 450.05 449.9893 42385500
2023-11-06 452.85 459.35 448.99 457.51 457.4483 40073300
2023-11-07 457.19 462.18 451.58 459.55 459.4880 34316500
2023-11-08 461.00 468.67 459.68 465.74 465.6772 34671900
2023-11-09 474.67 482.30 467.50 469.50 469.4367 54049600
2023-11-10 475.00 484.72 472.83 483.35 483.2849 42124500
2023-11-13 483.20 491.16 480.99 486.20 486.1345 38413600
2023-11-14 496.80 498.34 490.40 496.56 496.4930 41695400
2023-11-15 499.35 499.60 482.00 488.88 488.8141 47549700
2023-11-16 486.79 495.25 483.30 494.80 494.7333 33975600
2023-11-17 495.24 497.17 490.07 492.98 492.9135 32520500
2023-11-20 493.12 505.48 491.81 504.09 504.0220 41412000
2023-11-21 501.26 505.17 492.22 499.44 499.3727 56574700
2023-11-22 498.52 503.35 476.90 487.16 487.0943 89942000
2023-11-24 484.70 489.21 477.45 477.76 477.6956 29464500
2023-11-27 478.00 485.30 476.52 482.42 482.3550 39566200
2023-11-28 482.36 483.23 474.73 478.21 478.1455 40149100
2023-11-29 483.79 487.62 478.60 481.40 481.3351 38200500
2023-11-30 480.24 481.10 464.22 467.70 467.6370 52624700
2023-12-01 465.25 472.00 461.87 467.65 467.5869 36880900
2023-12-04 460.77 460.77 450.10 455.10 455.0387 43754300
2023-12-05 454.66 466.00 452.71 465.66 465.6382 37171800
2023-12-06 472.15 473.87 454.12 455.03 455.0087 38059000
2023-12-07 457.00 466.29 456.04 465.96 465.9381 35082300
2023-12-08 465.95 477.41 465.50 475.06 475.0377 35880300
2023-12-11 474.91 475.31 458.30 466.27 466.2481 50972800
2023-12-12 460.46 476.66 460.46 476.57 476.5476 37238700
2023-12-13 476.29 485.94 476.08 480.88 480.8575 44779200
2023-12-14 483.90 486.70 474.22 483.50 483.4773 39123200
2023-12-15 481.94 494.04 481.20 488.90 488.8771 47947800
2023-12-18 494.00 504.33 491.50 500.77 500.7465 41258700
2023-12-19 494.24 497.00 488.95 496.04 496.0168 46444400
2023-12-20 496.55 499.99 480.98 481.11 481.0874 39789400
2023-12-21 488.11 490.95 484.19 489.90 489.8770 30042500
2023-12-22 491.95 493.83 484.67 488.30 488.2771 25213900
2023-12-26 489.68 496.00 489.60 492.79 492.7669 24420000
2023-12-27 495.11 496.80 490.85 494.17 494.1468 23364800
2023-12-28 496.43 498.84 494.12 495.22 495.1968 24658700
2023-12-29 498.13 499.97 487.51 495.22 495.1968 38869000
2024-01-02 492.44 492.95 475.95 481.68 481.6574 41125400
2024-01-03 474.85 481.84 473.20 475.69 475.6677 32089600
2024-01-04 477.67 485.00 475.08 479.98 479.9575 30653500
2024-01-05 484.62 495.47 483.06 490.97 490.9470 41456800
2024-01-08 495.12 522.75 494.79 522.53 522.5055 64251000
2024-01-09 524.01 543.25 516.90 531.40 531.3751 77310000
2024-01-10 536.16 546.00 534.89 543.50 543.4745 53379600
2024-01-11 549.99 553.46 535.60 548.22 548.1943 59675900
2024-01-12 546.20 549.70 543.30 547.10 547.0743 35247900
2024-01-16 550.18 568.35 549.00 563.82 563.7936 44958000
2024-01-17 563.47 564.71 547.40 560.53 560.5037 47439400
2024-01-18 572.60 576.00 561.07 571.07 571.0432 49165000
2024-01-19 579.89 595.00 572.25 594.91 594.8821 54210300
2024-01-22 600.49 603.31 590.70 596.54 596.5120 45295500
2024-01-23 595.70 599.10 585.85 598.73 598.7019 29465400
2024-01-24 603.04 628.49 599.38 613.62 613.5912 56027100
2024-01-25 623.50 627.19 608.50 616.17 616.1411 48277700
2024-01-26 609.60 617.83 605.73 610.31 610.2814 39030900
2024-01-29 612.32 624.89 609.07 624.65 624.6207 34873300
2024-01-30 629.00 634.93 622.60 627.74 627.7106 41073500
2024-01-31 614.40 622.69 607.00 615.27 615.2411 45379500
2024-02-01 621.00 631.91 616.50 630.27 630.2405 36914600
2024-02-02 639.74 666.00 636.90 661.60 661.5690 47578000
2024-02-05 682.25 694.97 672.05 693.32 693.2875 68007800
2024-02-06 696.30 697.54 663.00 682.23 682.1980 68311100
2024-02-07 683.19 702.20 676.00 700.99 700.9571 49557500
2024-02-08 700.74 707.94 694.55 696.41 696.3773 41442200
2024-02-09 705.33 721.85 702.12 721.33 721.2962 43663700
2024-02-12 726.00 746.11 712.50 722.48 722.4461 61371000
2024-02-13 704.00 734.50 696.20 721.28 721.2462 60258000
2024-02-14 732.02 742.36 719.38 739.00 738.9653 50491700
2024-02-15 738.69 739.75 724.00 726.58 726.5460 42012200
2024-02-16 741.00 744.02 725.01 726.13 726.0959 49391800
2024-02-20 719.47 719.56 677.34 694.52 694.4874 70483300
2024-02-21 680.06 688.88 662.48 674.72 674.6883 69029800
2024-02-22 750.25 785.75 742.20 785.38 785.3431 86510000
2024-02-23 807.90 823.94 775.70 788.17 788.1330 82938800
2024-02-26 797.00 806.46 785.05 790.92 790.8829 50397300
2024-02-27 793.81 794.80 771.62 787.01 786.9731 39170500
2024-02-28 776.20 789.33 771.25 776.63 776.5936 39311000
2024-02-29 790.94 799.90 783.50 791.12 791.0829 50728900

Try gt()

gt()

gt is a package specifically for producing tables and allows much classification. Data is converted to a gt object and then formatting is applied.

gt() with formatting

Same data as before, just formatted using gt() and only showing the first 20 rows:

start_date <- min(NVIDIA$Date)
end_date <- max(NVIDIA$Date)
NVIDIA[1:20,] |>
  gt() |>
   fmt_currency(columns = -Volume) |>
   fmt_date(columns = Date, date_style = "wd_m_day_year") |>
   fmt_number(columns = 7, decimals = 0, sep_mark = ",", dec_mark = ".") 

Date Open High Low Close Adj Close Volume
Tue, Jan 3, 2023 $148.51 $149.96 $140.96 $143.15 $143.08 40,127,700
Wed, Jan 4, 2023 $145.67 $148.53 $142.41 $147.49 $147.42 43,132,400
Thu, Jan 5, 2023 $144.91 $145.64 $141.48 $142.65 $142.58 38,916,800
Fri, Jan 6, 2023 $144.74 $150.10 $140.34 $148.59 $148.52 40,504,400
Mon, Jan 9, 2023 $152.84 $160.56 $151.41 $156.28 $156.20 50,423,100
Tue, Jan 10, 2023 $155.07 $159.62 $154.72 $159.09 $159.01 38,410,100
Wed, Jan 11, 2023 $158.40 $160.28 $155.63 $160.01 $159.93 35,328,500
Thu, Jan 12, 2023 $161.00 $166.37 $154.92 $165.11 $165.03 55,140,900
Fri, Jan 13, 2023 $162.78 $169.22 $161.65 $168.99 $168.91 44,728,700
Tue, Jan 17, 2023 $168.99 $177.28 $168.99 $177.02 $176.93 51,110,200
Wed, Jan 18, 2023 $176.67 $178.73 $172.82 $173.77 $173.68 43,962,400
Thu, Jan 19, 2023 $170.36 $171.97 $167.31 $167.65 $167.57 45,293,200
Fri, Jan 20, 2023 $170.11 $178.56 $168.25 $178.39 $178.30 56,496,700
Mon, Jan 23, 2023 $180.64 $192.45 $178.18 $191.93 $191.84 65,516,300
Tue, Jan 24, 2023 $188.27 $194.95 $188.20 $192.65 $192.56 49,620,400
Wed, Jan 25, 2023 $189.13 $193.70 $185.80 $193.23 $193.14 44,953,700
Thu, Jan 26, 2023 $197.01 $201.66 $192.78 $198.02 $197.92 48,953,500
Fri, Jan 27, 2023 $194.62 $206.28 $194.05 $203.65 $203.55 54,214,200
Mon, Jan 30, 2023 $199.50 $201.40 $191.50 $191.62 $191.53 48,861,100
Tue, Jan 31, 2023 $191.70 $196.87 $189.50 $195.37 $195.27 49,801,700

gt() with header and note

Showing few rows, adding a table header and a source note:

start_date <- min(NVIDIA$Date)
end_date <- max(NVIDIA$Date)
NVIDIA[1:6,] |>
  gt() |>
  tab_header(
    title = md("**NVIDIA**"),
    subtitle = glue::glue("{start_date} to {end_date}")
  ) |>
  fmt_currency(columns = -Volume) |> 
  fmt_number(columns = Volume, decimals = 0, sep_mark = ",", dec_mark = ".") |>
  fmt_date(columns = Date, date_style = "wd_m_day_year") |>
 tab_source_note(
    source_note = md("**Source: Yahoo Finance**")
  ) 

NVIDIA
2023-01-03 to 2024-02-29
Date Open High Low Close Adj Close Volume
Tue, Jan 3, 2023 $148.51 $149.96 $140.96 $143.15 $143.08 40,127,700
Wed, Jan 4, 2023 $145.67 $148.53 $142.41 $147.49 $147.42 43,132,400
Thu, Jan 5, 2023 $144.91 $145.64 $141.48 $142.65 $142.58 38,916,800
Fri, Jan 6, 2023 $144.74 $150.10 $140.34 $148.59 $148.52 40,504,400
Mon, Jan 9, 2023 $152.84 $160.56 $151.41 $156.28 $156.20 50,423,100
Tue, Jan 10, 2023 $155.07 $159.62 $154.72 $159.09 $159.01 38,410,100
Source: Yahoo Finance

gt() with stubhead

start_date <- min(NVIDIA$Date)
end_date <- max(NVIDIA$Date)
NVIDIA |>
  gt(rowname_col = "Date") |>
  tab_header(
    title = md("**NVIDIA**"),
    subtitle = glue::glue("{start_date} to {end_date}")
  ) |>
  tab_stubhead(label = "Date") |>
  fmt_currency(columns = -Volume) |>
  fmt_number(columns = Volume, decimals = 0, sep_mark = ",", dec_mark = ".") |>
  fmt_date(columns = Date, date_style = "wd_m_day_year") |>
 tab_source_note(
    source_note = md("**Source: Yahoo Finance**")
  ) 

NVIDIA
2023-01-03 to 2024-02-29
Date Open High Low Close Adj Close Volume
Tue, Jan 3, 2023 $148.51 $149.96 $140.96 $143.15 $143.08 40,127,700
Wed, Jan 4, 2023 $145.67 $148.53 $142.41 $147.49 $147.42 43,132,400
Thu, Jan 5, 2023 $144.91 $145.64 $141.48 $142.65 $142.58 38,916,800
Fri, Jan 6, 2023 $144.74 $150.10 $140.34 $148.59 $148.52 40,504,400
Mon, Jan 9, 2023 $152.84 $160.56 $151.41 $156.28 $156.20 50,423,100
Tue, Jan 10, 2023 $155.07 $159.62 $154.72 $159.09 $159.01 38,410,100
Wed, Jan 11, 2023 $158.40 $160.28 $155.63 $160.01 $159.93 35,328,500
Thu, Jan 12, 2023 $161.00 $166.37 $154.92 $165.11 $165.03 55,140,900
Fri, Jan 13, 2023 $162.78 $169.22 $161.65 $168.99 $168.91 44,728,700
Tue, Jan 17, 2023 $168.99 $177.28 $168.99 $177.02 $176.93 51,110,200
Wed, Jan 18, 2023 $176.67 $178.73 $172.82 $173.77 $173.68 43,962,400
Thu, Jan 19, 2023 $170.36 $171.97 $167.31 $167.65 $167.57 45,293,200
Fri, Jan 20, 2023 $170.11 $178.56 $168.25 $178.39 $178.30 56,496,700
Mon, Jan 23, 2023 $180.64 $192.45 $178.18 $191.93 $191.84 65,516,300
Tue, Jan 24, 2023 $188.27 $194.95 $188.20 $192.65 $192.56 49,620,400
Wed, Jan 25, 2023 $189.13 $193.70 $185.80 $193.23 $193.14 44,953,700
Thu, Jan 26, 2023 $197.01 $201.66 $192.78 $198.02 $197.92 48,953,500
Fri, Jan 27, 2023 $194.62 $206.28 $194.05 $203.65 $203.55 54,214,200
Mon, Jan 30, 2023 $199.50 $201.40 $191.50 $191.62 $191.53 48,861,100
Tue, Jan 31, 2023 $191.70 $196.87 $189.50 $195.37 $195.27 49,801,700
Wed, Feb 1, 2023 $196.91 $211.92 $196.11 $209.43 $209.33 66,047,700
Thu, Feb 2, 2023 $210.00 $219.49 $207.00 $217.09 $216.98 56,427,600
Fri, Feb 3, 2023 $210.00 $217.45 $207.89 $211.00 $210.90 42,936,600
Mon, Feb 6, 2023 $208.06 $215.70 $207.86 $210.89 $210.79 45,219,700
Tue, Feb 7, 2023 $213.82 $222.59 $211.50 $221.73 $221.62 66,415,000
Wed, Feb 8, 2023 $223.87 $228.78 $220.08 $222.05 $221.94 55,965,100
Thu, Feb 9, 2023 $226.06 $230.20 $221.20 $223.37 $223.26 52,387,600
Fri, Feb 10, 2023 $216.90 $220.78 $208.11 $212.65 $212.55 55,073,700
Mon, Feb 13, 2023 $215.38 $220.48 $209.62 $217.88 $217.77 47,491,900
Tue, Feb 14, 2023 $215.78 $230.49 $213.66 $229.71 $229.60 67,547,400
Wed, Feb 15, 2023 $225.49 $228.55 $221.06 $227.64 $227.53 42,057,500
Thu, Feb 16, 2023 $221.33 $225.50 $219.27 $220.02 $219.91 41,202,600
Fri, Feb 17, 2023 $216.31 $217.40 $209.75 $213.88 $213.78 46,588,800
Tue, Feb 21, 2023 $210.00 $214.94 $206.18 $206.55 $206.45 41,001,500
Wed, Feb 22, 2023 $207.07 $211.04 $204.21 $207.54 $207.44 51,318,400
Thu, Feb 23, 2023 $234.40 $238.88 $230.25 $236.64 $236.52 111,799,500
Fri, Feb 24, 2023 $232.25 $234.74 $229.47 $232.86 $232.75 58,971,600
Mon, Feb 27, 2023 $236.70 $238.80 $234.54 $235.01 $234.89 45,299,400
Tue, Feb 28, 2023 $233.72 $238.25 $232.06 $232.16 $232.05 45,596,300
Wed, Mar 1, 2023 $231.92 $232.56 $225.08 $226.98 $226.87 46,002,600
Thu, Mar 2, 2023 $224.88 $233.80 $224.32 $233.14 $233.03 38,941,500
Fri, Mar 3, 2023 $233.20 $239.00 $231.30 $238.90 $238.78 41,239,300
Mon, Mar 6, 2023 $238.91 $242.48 $234.87 $235.54 $235.42 43,742,900
Tue, Mar 7, 2023 $236.00 $241.25 $232.41 $232.88 $232.81 51,515,400
Wed, Mar 8, 2023 $234.87 $242.00 $234.24 $241.81 $241.73 51,357,300
Thu, Mar 9, 2023 $241.75 $244.54 $233.83 $234.36 $234.28 50,125,700
Fri, Mar 10, 2023 $234.09 $236.27 $227.26 $229.65 $229.58 47,486,600
Mon, Mar 13, 2023 $227.52 $232.98 $222.97 $229.66 $229.59 42,189,000
Tue, Mar 14, 2023 $234.96 $242.19 $234.60 $240.63 $240.55 47,491,000
Wed, Mar 15, 2023 $237.61 $242.86 $233.60 $242.28 $242.20 52,448,600
Thu, Mar 16, 2023 $240.27 $255.88 $238.94 $255.41 $255.33 58,325,300
Fri, Mar 17, 2023 $259.82 $263.99 $256.68 $257.25 $257.17 84,854,700
Mon, Mar 20, 2023 $256.15 $260.24 $251.30 $259.00 $258.92 43,274,700
Tue, Mar 21, 2023 $261.80 $263.92 $253.81 $261.99 $261.91 54,740,800
Wed, Mar 22, 2023 $264.25 $275.89 $262.37 $264.68 $264.60 79,729,500
Thu, Mar 23, 2023 $271.15 $274.99 $266.90 $271.91 $271.82 56,488,900
Fri, Mar 24, 2023 $270.31 $271.67 $263.55 $267.79 $267.70 45,492,000
Mon, Mar 27, 2023 $268.37 $270.00 $263.65 $265.31 $265.22 36,102,600
Tue, Mar 28, 2023 $264.47 $265.13 $258.50 $264.10 $264.02 35,610,400
Wed, Mar 29, 2023 $268.25 $270.78 $265.97 $269.84 $269.75 39,369,400
Thu, Mar 30, 2023 $272.29 $274.99 $271.02 $273.83 $273.74 36,451,600
Fri, Mar 31, 2023 $271.40 $278.34 $271.05 $277.77 $277.68 43,393,300
Mon, Apr 3, 2023 $275.09 $280.00 $273.36 $279.65 $279.56 39,871,600
Tue, Apr 4, 2023 $279.66 $280.00 $273.07 $274.53 $274.44 36,859,200
Wed, Apr 5, 2023 $268.29 $269.98 $263.95 $268.81 $268.72 51,501,500
Thu, Apr 6, 2023 $265.84 $270.80 $264.27 $270.37 $270.28 39,765,400
Mon, Apr 10, 2023 $268.23 $276.21 $266.69 $275.79 $275.70 39,527,900
Tue, Apr 11, 2023 $277.24 $277.90 $271.26 $271.69 $271.60 31,437,800
Wed, Apr 12, 2023 $273.70 $274.68 $264.48 $264.95 $264.87 44,625,900
Thu, Apr 13, 2023 $267.34 $268.87 $263.29 $264.63 $264.55 35,361,500
Fri, Apr 14, 2023 $265.04 $268.83 $262.20 $267.58 $267.49 39,566,000
Mon, Apr 17, 2023 $265.65 $270.06 $264.33 $270.02 $269.93 32,147,100
Tue, Apr 18, 2023 $275.33 $281.10 $273.57 $276.67 $276.58 60,481,200
Wed, Apr 19, 2023 $273.61 $280.00 $272.32 $279.31 $279.22 35,866,000
Thu, Apr 20, 2023 $276.71 $280.30 $270.00 $271.04 $270.95 42,771,300
Fri, Apr 21, 2023 $269.52 $271.83 $267.22 $271.19 $271.10 34,510,300
Mon, Apr 24, 2023 $270.13 $273.66 $266.71 $270.42 $270.33 33,928,200
Tue, Apr 25, 2023 $270.78 $272.47 $262.25 $262.41 $262.33 37,852,700
Wed, Apr 26, 2023 $270.02 $273.30 $267.05 $269.56 $269.47 40,633,700
Thu, Apr 27, 2023 $273.63 $274.95 $266.25 $272.26 $272.17 37,716,100
Fri, Apr 28, 2023 $272.25 $277.58 $270.71 $277.49 $277.40 29,168,700
Mon, May 1, 2023 $278.40 $290.58 $277.80 $289.10 $289.01 57,032,900
Tue, May 2, 2023 $286.80 $288.36 $280.83 $282.10 $282.01 40,273,000
Wed, May 3, 2023 $278.40 $283.67 $274.72 $278.02 $277.93 38,338,700
Thu, May 4, 2023 $276.51 $278.59 $272.40 $275.62 $275.53 32,185,000
Fri, May 5, 2023 $278.26 $287.55 $277.31 $286.80 $286.71 36,101,400
Mon, May 8, 2023 $285.22 $292.20 $283.50 $291.51 $291.42 34,497,900
Tue, May 9, 2023 $288.99 $289.73 $284.50 $285.71 $285.62 31,486,900
Wed, May 10, 2023 $290.05 $291.13 $284.61 $288.85 $288.76 36,935,000
Thu, May 11, 2023 $288.96 $289.50 $282.46 $285.78 $285.69 32,214,900
Fri, May 12, 2023 $285.29 $287.80 $280.46 $283.40 $283.31 27,402,700
Mon, May 15, 2023 $285.08 $289.69 $281.52 $289.53 $289.44 29,392,600
Tue, May 16, 2023 $288.41 $298.70 $288.32 $292.13 $292.04 44,940,500
Wed, May 17, 2023 $295.84 $301.99 $294.30 $301.78 $301.68 43,253,500
Thu, May 18, 2023 $304.10 $318.28 $303.20 $316.78 $316.68 74,872,500
Fri, May 19, 2023 $315.36 $315.80 $309.16 $312.64 $312.54 47,312,400
Mon, May 22, 2023 $309.01 $315.20 $306.80 $311.76 $311.66 37,200,000
Tue, May 23, 2023 $310.00 $312.88 $306.31 $306.88 $306.78 35,625,300
Wed, May 24, 2023 $302.10 $306.07 $298.06 $305.38 $305.28 72,141,900
Thu, May 25, 2023 $385.23 $394.80 $366.35 $379.80 $379.68 154,391,100
Fri, May 26, 2023 $378.90 $391.70 $375.50 $389.46 $389.34 71,439,700
Tue, May 30, 2023 $405.95 $419.38 $399.49 $401.11 $400.98 92,340,100
Wed, May 31, 2023 $394.88 $402.95 $378.22 $378.34 $378.22 100,258,000
Thu, Jun 1, 2023 $384.89 $400.50 $383.40 $397.70 $397.57 63,587,300
Fri, Jun 2, 2023 $400.97 $405.00 $390.58 $393.27 $393.14 48,165,500
Mon, Jun 5, 2023 $389.09 $395.65 $387.07 $391.71 $391.58 39,609,400
Tue, Jun 6, 2023 $388.30 $391.60 $381.48 $386.54 $386.42 38,872,900
Wed, Jun 7, 2023 $389.15 $394.99 $373.56 $374.75 $374.67 51,199,800
Thu, Jun 8, 2023 $377.24 $388.64 $375.05 $385.10 $385.02 41,777,200
Fri, Jun 9, 2023 $390.37 $397.11 $385.67 $387.70 $387.62 42,722,000
Mon, Jun 12, 2023 $392.00 $395.30 $386.18 $394.82 $394.73 38,870,100
Tue, Jun 13, 2023 $401.86 $411.01 $397.40 $410.22 $410.13 61,320,800
Wed, Jun 14, 2023 $408.24 $430.00 $405.52 $429.97 $429.88 74,046,500
Thu, Jun 15, 2023 $426.02 $432.89 $421.47 $426.53 $426.44 56,862,200
Fri, Jun 16, 2023 $434.50 $437.21 $426.61 $426.92 $426.83 65,475,500
Tue, Jun 20, 2023 $429.98 $439.90 $426.74 $438.08 $437.98 45,115,300
Wed, Jun 21, 2023 $435.01 $436.15 $420.80 $430.45 $430.36 55,160,300
Thu, Jun 22, 2023 $422.53 $434.26 $422.34 $430.25 $430.16 41,773,700
Fri, Jun 23, 2023 $424.64 $428.09 $420.15 $422.09 $422.00 35,632,300
Mon, Jun 26, 2023 $424.61 $427.64 $401.00 $406.32 $406.23 59,432,200
Tue, Jun 27, 2023 $407.99 $419.40 $404.48 $418.76 $418.67 46,217,500
Wed, Jun 28, 2023 $406.60 $418.45 $405.18 $411.17 $411.08 58,263,900
Thu, Jun 29, 2023 $415.58 $416.00 $406.00 $408.22 $408.13 38,051,400
Fri, Jun 30, 2023 $416.80 $425.50 $415.01 $423.02 $422.93 50,053,400
Mon, Jul 3, 2023 $425.17 $428.98 $422.02 $424.13 $424.04 19,820,900
Wed, Jul 5, 2023 $421.35 $431.77 $420.85 $423.17 $423.08 32,361,800
Thu, Jul 6, 2023 $418.44 $421.79 $413.46 $421.03 $420.94 30,358,200
Fri, Jul 7, 2023 $423.22 $432.14 $421.80 $425.03 $424.94 35,525,300
Mon, Jul 10, 2023 $426.57 $428.11 $416.49 $421.80 $421.71 35,390,800
Tue, Jul 11, 2023 $424.81 $427.58 $420.67 $424.05 $423.96 29,824,400
Wed, Jul 12, 2023 $430.33 $439.35 $427.77 $439.02 $438.92 48,127,700
Thu, Jul 13, 2023 $445.18 $461.55 $444.92 $459.77 $459.67 47,820,400
Fri, Jul 14, 2023 $465.83 $480.88 $450.60 $454.69 $454.59 77,066,400
Mon, Jul 17, 2023 $462.89 $464.96 $452.62 $464.61 $464.51 51,048,800
Tue, Jul 18, 2023 $467.01 $478.96 $457.34 $474.94 $474.84 57,019,000
Wed, Jul 19, 2023 $474.64 $478.18 $467.42 $470.77 $470.67 42,750,200
Thu, Jul 20, 2023 $465.07 $470.87 $450.62 $455.20 $455.10 53,786,500
Fri, Jul 21, 2023 $457.88 $458.66 $441.00 $443.09 $442.99 96,283,200
Mon, Jul 24, 2023 $447.31 $451.09 $440.40 $446.12 $446.02 38,251,600
Tue, Jul 25, 2023 $449.41 $461.83 $449.23 $456.79 $456.69 34,808,100
Wed, Jul 26, 2023 $460.21 $460.53 $446.30 $454.52 $454.42 36,423,700
Thu, Jul 27, 2023 $465.19 $473.95 $457.50 $459.00 $458.90 45,597,600
Fri, Jul 28, 2023 $466.68 $470.27 $463.81 $467.50 $467.40 33,119,400
Mon, Jul 31, 2023 $467.54 $471.30 $465.06 $467.29 $467.19 25,105,500
Tue, Aug 1, 2023 $464.60 $469.00 $460.27 $465.07 $464.97 23,785,800
Wed, Aug 2, 2023 $458.31 $458.40 $433.87 $442.69 $442.59 53,014,200
Thu, Aug 3, 2023 $438.00 $451.18 $438.00 $445.15 $445.05 32,417,600
Fri, Aug 4, 2023 $449.85 $456.42 $443.93 $446.80 $446.70 36,225,800
Mon, Aug 7, 2023 $451.11 $455.40 $445.63 $454.17 $454.07 32,215,400
Tue, Aug 8, 2023 $448.53 $452.42 $440.56 $446.64 $446.54 35,384,300
Wed, Aug 9, 2023 $442.74 $443.12 $421.34 $425.54 $425.45 58,644,900
Thu, Aug 10, 2023 $421.60 $435.74 $418.35 $423.88 $423.79 49,270,500
Fri, Aug 11, 2023 $417.51 $420.18 $406.39 $408.55 $408.46 53,200,900
Mon, Aug 14, 2023 $404.86 $438.00 $403.11 $437.53 $437.43 69,028,600
Tue, Aug 15, 2023 $445.60 $452.68 $437.10 $439.40 $439.30 67,651,200
Wed, Aug 16, 2023 $445.20 $446.75 $434.06 $434.86 $434.77 52,745,100
Thu, Aug 17, 2023 $439.70 $440.62 $430.01 $433.44 $433.35 45,239,500
Fri, Aug 18, 2023 $426.35 $435.78 $416.60 $432.99 $432.90 58,262,200
Mon, Aug 21, 2023 $444.94 $470.65 $442.22 $469.67 $469.57 69,257,300
Tue, Aug 22, 2023 $481.35 $481.87 $453.33 $456.68 $456.58 75,720,700
Wed, Aug 23, 2023 $458.66 $472.00 $452.08 $471.16 $471.06 77,904,600
Thu, Aug 24, 2023 $502.16 $502.66 $471.59 $471.63 $471.53 115,604,400
Fri, Aug 25, 2023 $470.12 $478.05 $450.24 $460.18 $460.08 92,534,100
Mon, Aug 28, 2023 $464.82 $469.80 $448.88 $468.35 $468.25 68,519,200
Tue, Aug 29, 2023 $466.66 $490.81 $463.91 $487.84 $487.73 70,139,700
Wed, Aug 30, 2023 $490.44 $499.27 $484.25 $492.64 $492.53 73,520,600
Thu, Aug 31, 2023 $493.80 $497.44 $489.58 $493.55 $493.44 52,857,000
Fri, Sep 1, 2023 $497.62 $498.00 $481.42 $485.09 $484.98 46,319,100
Tue, Sep 5, 2023 $482.23 $488.51 $478.60 $485.48 $485.37 38,265,300
Wed, Sep 6, 2023 $484.41 $485.49 $465.80 $470.61 $470.55 46,867,000
Thu, Sep 7, 2023 $455.25 $463.44 $451.52 $462.41 $462.35 43,333,000
Fri, Sep 8, 2023 $459.42 $466.06 $452.71 $455.72 $455.66 47,306,900
Mon, Sep 11, 2023 $461.48 $461.63 $443.12 $451.78 $451.72 47,396,600
Tue, Sep 12, 2023 $447.38 $456.73 $445.31 $448.70 $448.64 34,925,600
Wed, Sep 13, 2023 $446.00 $459.30 $445.03 $454.85 $454.79 39,835,500
Thu, Sep 14, 2023 $459.50 $459.87 $451.31 $455.81 $455.75 37,009,700
Fri, Sep 15, 2023 $453.41 $455.99 $438.08 $439.00 $438.94 50,571,300
Mon, Sep 18, 2023 $427.48 $442.42 $420.00 $439.66 $439.60 50,027,100
Tue, Sep 19, 2023 $438.33 $439.66 $430.02 $435.20 $435.14 37,306,400
Wed, Sep 20, 2023 $436.00 $439.03 $422.23 $422.39 $422.33 36,710,800
Thu, Sep 21, 2023 $415.83 $421.00 $409.80 $410.17 $410.11 44,893,000
Fri, Sep 22, 2023 $415.72 $421.15 $412.31 $416.10 $416.04 47,923,600
Mon, Sep 25, 2023 $415.91 $425.36 $411.77 $422.22 $422.16 41,909,100
Tue, Sep 26, 2023 $420.01 $428.20 $416.55 $419.11 $419.05 40,228,200
Wed, Sep 27, 2023 $423.30 $428.72 $416.29 $424.68 $424.62 44,493,500
Thu, Sep 28, 2023 $424.60 $434.46 $421.15 $430.89 $430.83 42,466,300
Fri, Sep 29, 2023 $438.27 $441.44 $433.07 $434.99 $434.93 39,722,100
Mon, Oct 2, 2023 $440.30 $451.75 $438.61 $447.82 $447.76 43,329,800
Tue, Oct 3, 2023 $448.08 $451.30 $432.46 $435.17 $435.11 47,085,000
Wed, Oct 4, 2023 $437.42 $441.43 $432.92 $440.41 $440.35 36,182,100
Thu, Oct 5, 2023 $440.50 $449.00 $438.88 $446.88 $446.82 39,348,300
Fri, Oct 6, 2023 $441.93 $457.89 $440.26 $457.62 $457.56 43,339,700
Mon, Oct 9, 2023 $448.42 $456.05 $443.68 $452.73 $452.67 40,967,500
Tue, Oct 10, 2023 $453.10 $462.59 $450.88 $457.98 $457.92 36,858,200
Wed, Oct 11, 2023 $461.96 $468.59 $460.50 $468.06 $468.00 37,813,700
Thu, Oct 12, 2023 $467.77 $476.09 $463.30 $469.45 $469.39 48,132,500
Fri, Oct 13, 2023 $469.60 $471.16 $452.80 $454.61 $454.55 47,411,500
Mon, Oct 16, 2023 $450.63 $462.25 $449.12 $460.95 $460.89 37,509,900
Tue, Oct 17, 2023 $440.00 $447.54 $424.80 $439.38 $439.32 81,233,300
Wed, Oct 18, 2023 $425.91 $432.19 $418.25 $421.96 $421.90 62,729,400
Thu, Oct 19, 2023 $428.11 $432.97 $418.82 $421.01 $420.95 50,123,300
Fri, Oct 20, 2023 $418.90 $424.70 $410.78 $413.87 $413.81 47,638,100
Mon, Oct 23, 2023 $412.29 $432.48 $409.45 $429.75 $429.69 47,853,000
Tue, Oct 24, 2023 $430.77 $436.97 $426.91 $436.63 $436.57 40,146,300
Wed, Oct 25, 2023 $433.98 $436.50 $415.55 $417.79 $417.73 39,837,900
Thu, Oct 26, 2023 $418.53 $422.56 $398.80 $403.26 $403.21 54,100,100
Fri, Oct 27, 2023 $411.30 $412.06 $400.15 $405.00 $404.95 41,678,400
Mon, Oct 30, 2023 $410.87 $417.66 $404.81 $411.61 $411.55 38,802,800
Tue, Oct 31, 2023 $404.50 $408.79 $392.30 $407.80 $407.74 51,796,900
Wed, Nov 1, 2023 $408.84 $423.81 $408.69 $423.25 $423.19 43,759,300
Thu, Nov 2, 2023 $433.28 $438.84 $428.94 $435.06 $435.00 40,917,200
Fri, Nov 3, 2023 $440.20 $453.09 $437.23 $450.05 $449.99 42,385,500
Mon, Nov 6, 2023 $452.85 $459.35 $448.99 $457.51 $457.45 40,073,300
Tue, Nov 7, 2023 $457.19 $462.18 $451.58 $459.55 $459.49 34,316,500
Wed, Nov 8, 2023 $461.00 $468.67 $459.68 $465.74 $465.68 34,671,900
Thu, Nov 9, 2023 $474.67 $482.30 $467.50 $469.50 $469.44 54,049,600
Fri, Nov 10, 2023 $475.00 $484.72 $472.83 $483.35 $483.28 42,124,500
Mon, Nov 13, 2023 $483.20 $491.16 $480.99 $486.20 $486.13 38,413,600
Tue, Nov 14, 2023 $496.80 $498.34 $490.40 $496.56 $496.49 41,695,400
Wed, Nov 15, 2023 $499.35 $499.60 $482.00 $488.88 $488.81 47,549,700
Thu, Nov 16, 2023 $486.79 $495.25 $483.30 $494.80 $494.73 33,975,600
Fri, Nov 17, 2023 $495.24 $497.17 $490.07 $492.98 $492.91 32,520,500
Mon, Nov 20, 2023 $493.12 $505.48 $491.81 $504.09 $504.02 41,412,000
Tue, Nov 21, 2023 $501.26 $505.17 $492.22 $499.44 $499.37 56,574,700
Wed, Nov 22, 2023 $498.52 $503.35 $476.90 $487.16 $487.09 89,942,000
Fri, Nov 24, 2023 $484.70 $489.21 $477.45 $477.76 $477.70 29,464,500
Mon, Nov 27, 2023 $478.00 $485.30 $476.52 $482.42 $482.35 39,566,200
Tue, Nov 28, 2023 $482.36 $483.23 $474.73 $478.21 $478.15 40,149,100
Wed, Nov 29, 2023 $483.79 $487.62 $478.60 $481.40 $481.34 38,200,500
Thu, Nov 30, 2023 $480.24 $481.10 $464.22 $467.70 $467.64 52,624,700
Fri, Dec 1, 2023 $465.25 $472.00 $461.87 $467.65 $467.59 36,880,900
Mon, Dec 4, 2023 $460.77 $460.77 $450.10 $455.10 $455.04 43,754,300
Tue, Dec 5, 2023 $454.66 $466.00 $452.71 $465.66 $465.64 37,171,800
Wed, Dec 6, 2023 $472.15 $473.87 $454.12 $455.03 $455.01 38,059,000
Thu, Dec 7, 2023 $457.00 $466.29 $456.04 $465.96 $465.94 35,082,300
Fri, Dec 8, 2023 $465.95 $477.41 $465.50 $475.06 $475.04 35,880,300
Mon, Dec 11, 2023 $474.91 $475.31 $458.30 $466.27 $466.25 50,972,800
Tue, Dec 12, 2023 $460.46 $476.66 $460.46 $476.57 $476.55 37,238,700
Wed, Dec 13, 2023 $476.29 $485.94 $476.08 $480.88 $480.86 44,779,200
Thu, Dec 14, 2023 $483.90 $486.70 $474.22 $483.50 $483.48 39,123,200
Fri, Dec 15, 2023 $481.94 $494.04 $481.20 $488.90 $488.88 47,947,800
Mon, Dec 18, 2023 $494.00 $504.33 $491.50 $500.77 $500.75 41,258,700
Tue, Dec 19, 2023 $494.24 $497.00 $488.95 $496.04 $496.02 46,444,400
Wed, Dec 20, 2023 $496.55 $499.99 $480.98 $481.11 $481.09 39,789,400
Thu, Dec 21, 2023 $488.11 $490.95 $484.19 $489.90 $489.88 30,042,500
Fri, Dec 22, 2023 $491.95 $493.83 $484.67 $488.30 $488.28 25,213,900
Tue, Dec 26, 2023 $489.68 $496.00 $489.60 $492.79 $492.77 24,420,000
Wed, Dec 27, 2023 $495.11 $496.80 $490.85 $494.17 $494.15 23,364,800
Thu, Dec 28, 2023 $496.43 $498.84 $494.12 $495.22 $495.20 24,658,700
Fri, Dec 29, 2023 $498.13 $499.97 $487.51 $495.22 $495.20 38,869,000
Tue, Jan 2, 2024 $492.44 $492.95 $475.95 $481.68 $481.66 41,125,400
Wed, Jan 3, 2024 $474.85 $481.84 $473.20 $475.69 $475.67 32,089,600
Thu, Jan 4, 2024 $477.67 $485.00 $475.08 $479.98 $479.96 30,653,500
Fri, Jan 5, 2024 $484.62 $495.47 $483.06 $490.97 $490.95 41,456,800
Mon, Jan 8, 2024 $495.12 $522.75 $494.79 $522.53 $522.51 64,251,000
Tue, Jan 9, 2024 $524.01 $543.25 $516.90 $531.40 $531.38 77,310,000
Wed, Jan 10, 2024 $536.16 $546.00 $534.89 $543.50 $543.47 53,379,600
Thu, Jan 11, 2024 $549.99 $553.46 $535.60 $548.22 $548.19 59,675,900
Fri, Jan 12, 2024 $546.20 $549.70 $543.30 $547.10 $547.07 35,247,900
Tue, Jan 16, 2024 $550.18 $568.35 $549.00 $563.82 $563.79 44,958,000
Wed, Jan 17, 2024 $563.47 $564.71 $547.40 $560.53 $560.50 47,439,400
Thu, Jan 18, 2024 $572.60 $576.00 $561.07 $571.07 $571.04 49,165,000
Fri, Jan 19, 2024 $579.89 $595.00 $572.25 $594.91 $594.88 54,210,300
Mon, Jan 22, 2024 $600.49 $603.31 $590.70 $596.54 $596.51 45,295,500
Tue, Jan 23, 2024 $595.70 $599.10 $585.85 $598.73 $598.70 29,465,400
Wed, Jan 24, 2024 $603.04 $628.49 $599.38 $613.62 $613.59 56,027,100
Thu, Jan 25, 2024 $623.50 $627.19 $608.50 $616.17 $616.14 48,277,700
Fri, Jan 26, 2024 $609.60 $617.83 $605.73 $610.31 $610.28 39,030,900
Mon, Jan 29, 2024 $612.32 $624.89 $609.07 $624.65 $624.62 34,873,300
Tue, Jan 30, 2024 $629.00 $634.93 $622.60 $627.74 $627.71 41,073,500
Wed, Jan 31, 2024 $614.40 $622.69 $607.00 $615.27 $615.24 45,379,500
Thu, Feb 1, 2024 $621.00 $631.91 $616.50 $630.27 $630.24 36,914,600
Fri, Feb 2, 2024 $639.74 $666.00 $636.90 $661.60 $661.57 47,578,000
Mon, Feb 5, 2024 $682.25 $694.97 $672.05 $693.32 $693.29 68,007,800
Tue, Feb 6, 2024 $696.30 $697.54 $663.00 $682.23 $682.20 68,311,100
Wed, Feb 7, 2024 $683.19 $702.20 $676.00 $700.99 $700.96 49,557,500
Thu, Feb 8, 2024 $700.74 $707.94 $694.55 $696.41 $696.38 41,442,200
Fri, Feb 9, 2024 $705.33 $721.85 $702.12 $721.33 $721.30 43,663,700
Mon, Feb 12, 2024 $726.00 $746.11 $712.50 $722.48 $722.45 61,371,000
Tue, Feb 13, 2024 $704.00 $734.50 $696.20 $721.28 $721.25 60,258,000
Wed, Feb 14, 2024 $732.02 $742.36 $719.38 $739.00 $738.97 50,491,700
Thu, Feb 15, 2024 $738.69 $739.75 $724.00 $726.58 $726.55 42,012,200
Fri, Feb 16, 2024 $741.00 $744.02 $725.01 $726.13 $726.10 49,391,800
Tue, Feb 20, 2024 $719.47 $719.56 $677.34 $694.52 $694.49 70,483,300
Wed, Feb 21, 2024 $680.06 $688.88 $662.48 $674.72 $674.69 69,029,800
Thu, Feb 22, 2024 $750.25 $785.75 $742.20 $785.38 $785.34 86,510,000
Fri, Feb 23, 2024 $807.90 $823.94 $775.70 $788.17 $788.13 82,938,800
Mon, Feb 26, 2024 $797.00 $806.46 $785.05 $790.92 $790.88 50,397,300
Tue, Feb 27, 2024 $793.81 $794.80 $771.62 $787.01 $786.97 39,170,500
Wed, Feb 28, 2024 $776.20 $789.33 $771.25 $776.63 $776.59 39,311,000
Thu, Feb 29, 2024 $790.94 $799.90 $783.50 $791.12 $791.08 50,728,900
Source: Yahoo Finance

Aggregate to Month

monthly_summary <- NVIDIA %>% 
  mutate(Year = year(Date), Month = month(Date)) %>%
  group_by(Year, Month) %>%
  summarise(
    Avg_Open = round(mean(Open, na.rm = TRUE), digits =2),
    Avg_Close = round(mean(Close, na.rm = TRUE), digits =2),
    Avg_Volume = mean(Volume, na.rm = TRUE),
    Total_Volume = sum(Volume, na.rm = TRUE)
  ) %>%
  ungroup()
kable(monthly_summary)
Year Month Avg_Open Avg_Close Avg_Volume Total_Volume
2023 1 170.05 172.73 47274800 945496000
2023 2 218.63 220.43 54702521 1039347900
2023 3 249.75 251.07 48972743 1126373100
2023 4 271.48 271.49 39136426 743592100
2023 5 309.62 310.57 53165273 1169636000
2023 6 407.92 409.22 50105200 1052209200
2023 7 448.24 447.63 43524475 870489500
2023 8 453.34 452.54 59267113 1363143600
2023 9 445.11 443.24 42875505 857510100
2023 10 436.13 436.35 46087168 1013917700
2023 11 474.59 475.31 43542205 914386300
2023 12 479.87 480.70 37047585 740951700
2024 1 558.82 562.59 46208824 970385300
2024 2 724.29 725.50 55378460 1107569200

Row groups

monthly_summary[,-1] |> 
  gt() |>
  tab_row_group(
    label = "2023",
    rows = 1:12
  ) |>
  tab_row_group(
    label = "2024",
    rows = 13:14
  )  |>
  fmt_number(columns = c(Avg_Volume, Total_Volume), decimals = 0, sep_mark = ",", dec_mark = ".") |>
  fmt_currency(columns = -c(Month, Avg_Volume, Total_Volume))

Month Avg_Open Avg_Close Avg_Volume Total_Volume
2024
1 $558.82 $562.59 46,208,824 970,385,300
2 $724.29 $725.50 55,378,460 1,107,569,200
2023
1 $170.05 $172.73 47,274,800 945,496,000
2 $218.63 $220.43 54,702,521 1,039,347,900
3 $249.75 $251.07 48,972,743 1,126,373,100
4 $271.48 $271.49 39,136,426 743,592,100
5 $309.62 $310.57 53,165,273 1,169,636,000
6 $407.92 $409.22 50,105,200 1,052,209,200
7 $448.24 $447.63 43,524,475 870,489,500
8 $453.34 $452.54 59,267,113 1,363,143,600
9 $445.11 $443.24 42,875,505 857,510,100
10 $436.13 $436.35 46,087,168 1,013,917,700
11 $474.59 $475.31 43,542,205 914,386,300
12 $479.87 $480.70 37,047,585 740,951,700

Column groups

monthly_summary[,-1] |> 
  gt() |>
  tab_spanner(
    label = "Price",
    columns = c(Avg_Open, Avg_Close)) |>
  tab_spanner(
    label = "Volume",
    columns = c(Avg_Volume, Total_Volume)) |>
  tab_row_group(
    label = "2023",
    rows = 1:12
  ) |>
  tab_row_group(
    label = "2024",
    rows = 13:14
  )  |>
  fmt_number(columns = c(Avg_Volume, Total_Volume), decimals = 0, sep_mark = ",", dec_mark = ".") |>
  fmt_currency(columns = -c(Month, Avg_Volume, Total_Volume))

Month Price Volume
Avg_Open Avg_Close Avg_Volume Total_Volume
2024
1 $558.82 $562.59 46,208,824 970,385,300
2 $724.29 $725.50 55,378,460 1,107,569,200
2023
1 $170.05 $172.73 47,274,800 945,496,000
2 $218.63 $220.43 54,702,521 1,039,347,900
3 $249.75 $251.07 48,972,743 1,126,373,100
4 $271.48 $271.49 39,136,426 743,592,100
5 $309.62 $310.57 53,165,273 1,169,636,000
6 $407.92 $409.22 50,105,200 1,052,209,200
7 $448.24 $447.63 43,524,475 870,489,500
8 $453.34 $452.54 59,267,113 1,363,143,600
9 $445.11 $443.24 42,875,505 857,510,100
10 $436.13 $436.35 46,087,168 1,013,917,700
11 $474.59 $475.31 43,542,205 914,386,300
12 $479.87 $480.70 37,047,585 740,951,700

Labels

monthly_summary[,-1] |> 
  gt() |>
  tab_spanner(
    label = "Price",
    columns = c(Avg_Open, Avg_Close)) |>
  tab_spanner(
    label = "Volume",
    columns = c(Avg_Volume, Total_Volume)) |>
  tab_row_group(
    label = "2023",
    rows = 1:12
  ) |>
  tab_row_group(
    label = "2024",
    rows = 13:14
  )  |>
  cols_label(
    Avg_Open = html("Avg. Open"),
    Avg_Close = html("Avg. Close"),
    Avg_Volume = html("Avg. Volume"),
    Total_Volume = html("Tot Volume")
  ) |>
  fmt_number(columns = c(Avg_Volume, Total_Volume), decimals = 0, sep_mark = ",", dec_mark = ".") |>
  fmt_currency(columns = -c(Month, Avg_Volume, Total_Volume))

Month Price Volume
Avg. Open Avg. Close Avg. Volume Tot Volume
2024
1 $558.82 $562.59 46,208,824 970,385,300
2 $724.29 $725.50 55,378,460 1,107,569,200
2023
1 $170.05 $172.73 47,274,800 945,496,000
2 $218.63 $220.43 54,702,521 1,039,347,900
3 $249.75 $251.07 48,972,743 1,126,373,100
4 $271.48 $271.49 39,136,426 743,592,100
5 $309.62 $310.57 53,165,273 1,169,636,000
6 $407.92 $409.22 50,105,200 1,052,209,200
7 $448.24 $447.63 43,524,475 870,489,500
8 $453.34 $452.54 59,267,113 1,363,143,600
9 $445.11 $443.24 42,875,505 857,510,100
10 $436.13 $436.35 46,087,168 1,013,917,700
11 $474.59 $475.31 43,542,205 914,386,300
12 $479.87 $480.70 37,047,585 740,951,700

Federal Reserve Data

FRED <- read_csv("https://raw.githubusercontent.com/lewv/S24STATS101A/main/data/fredgraph.csv", 
    col_types = cols(DATE = col_date(format = "%Y-%m-%d"), 
        T10YIE = col_number()))
monthly_FRED <- FRED %>% 
  mutate(Year = year(DATE), Month = month(DATE)) %>%
  group_by(Year, Month) %>%
  summarise(
    Avg_Inf= round(mean(T10YIE, na.rm = TRUE), digits =2)
  ) %>%
  ungroup()
kable(monthly_FRED)
Year Month Avg_Inf
2019 5 1.75
2019 6 1.70
2019 7 1.75
2019 8 1.59
2019 9 1.59
2019 10 1.56
2019 11 1.64
2019 12 1.72
2020 1 1.72
2020 2 1.62
2020 3 0.99
2020 4 1.10
2020 5 1.12
2020 6 1.27
2020 7 1.46
2020 8 1.66
2020 9 1.66
2020 10 1.70
2020 11 1.71
2020 12 1.92
2021 1 2.08
2021 2 2.18
2021 3 2.28
2021 4 2.35
2021 5 2.47
2021 6 2.34
2021 7 2.33
2021 8 2.35
2021 9 2.34
2021 10 2.54
2021 11 2.62
2021 12 2.46
2022 1 2.45
2022 2 2.46
2022 3 2.85
2022 4 2.88
2022 5 2.69
2022 6 2.62
2022 7 2.36
2022 8 2.51
2022 9 2.38
2022 10 2.39
2022 11 2.37
2022 12 2.26
2023 1 2.24
2023 2 2.33
2023 3 2.30
2023 4 2.27
2023 5 2.21
2023 6 2.20
2023 7 2.30
2023 8 2.34
2023 9 2.34
2023 10 2.39
2023 11 2.30
2023 12 2.18
2024 1 2.27
2024 2 2.28
2024 3 2.31
2024 4 2.39
2024 5 2.33
glimpse(monthly_FRED) 
Rows: 61
Columns: 3
$ Year    <dbl> 2019, 2019, 2019, 2019, 2019, 2019, 2019, 2019, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2020, 2021, …
$ Month   <dbl> 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2, 3, 4, 5, 6, 7, …
$ Avg_Inf <dbl> 1.75, 1.70, 1.75, 1.59, 1.59, 1.56, 1.64, 1.72, 1.72, 1.62, 0.99, 1.10, 1.12, 1.27, 1.46, 1.66, 1.66, 1.70, 1.71, 1.92, 2.08, …

Add Color

monthly_FRED |> 
  gt() |>
  data_color(
    columns = Avg_Inf,
    method = "numeric",
    palette = c("red", "blue")) |>
  fmt_percent(columns = Avg_Inf, scale_values = FALSE)

Year Month Avg_Inf
2019 5 1.75%
2019 6 1.70%
2019 7 1.75%
2019 8 1.59%
2019 9 1.59%
2019 10 1.56%
2019 11 1.64%
2019 12 1.72%
2020 1 1.72%
2020 2 1.62%
2020 3 0.99%
2020 4 1.10%
2020 5 1.12%
2020 6 1.27%
2020 7 1.46%
2020 8 1.66%
2020 9 1.66%
2020 10 1.70%
2020 11 1.71%
2020 12 1.92%
2021 1 2.08%
2021 2 2.18%
2021 3 2.28%
2021 4 2.35%
2021 5 2.47%
2021 6 2.34%
2021 7 2.33%
2021 8 2.35%
2021 9 2.34%
2021 10 2.54%
2021 11 2.62%
2021 12 2.46%
2022 1 2.45%
2022 2 2.46%
2022 3 2.85%
2022 4 2.88%
2022 5 2.69%
2022 6 2.62%
2022 7 2.36%
2022 8 2.51%
2022 9 2.38%
2022 10 2.39%
2022 11 2.37%
2022 12 2.26%
2023 1 2.24%
2023 2 2.33%
2023 3 2.30%
2023 4 2.27%
2023 5 2.21%
2023 6 2.20%
2023 7 2.30%
2023 8 2.34%
2023 9 2.34%
2023 10 2.39%
2023 11 2.30%
2023 12 2.18%
2024 1 2.27%
2024 2 2.28%
2024 3 2.31%
2024 4 2.39%
2024 5 2.33%

Conditional Color with limits

monthly_FRED |> 
  gt() |>
  data_color(
    columns = Avg_Inf,
    rows = Avg_Inf < 2.00,
    method = "numeric",
    palette = c("BuPu")) |>
  fmt_percent(columns = Avg_Inf, scale_values = FALSE)

Year Month Avg_Inf
2019 5 1.75%
2019 6 1.70%
2019 7 1.75%
2019 8 1.59%
2019 9 1.59%
2019 10 1.56%
2019 11 1.64%
2019 12 1.72%
2020 1 1.72%
2020 2 1.62%
2020 3 0.99%
2020 4 1.10%
2020 5 1.12%
2020 6 1.27%
2020 7 1.46%
2020 8 1.66%
2020 9 1.66%
2020 10 1.70%
2020 11 1.71%
2020 12 1.92%
2021 1 2.08%
2021 2 2.18%
2021 3 2.28%
2021 4 2.35%
2021 5 2.47%
2021 6 2.34%
2021 7 2.33%
2021 8 2.35%
2021 9 2.34%
2021 10 2.54%
2021 11 2.62%
2021 12 2.46%
2022 1 2.45%
2022 2 2.46%
2022 3 2.85%
2022 4 2.88%
2022 5 2.69%
2022 6 2.62%
2022 7 2.36%
2022 8 2.51%
2022 9 2.38%
2022 10 2.39%
2022 11 2.37%
2022 12 2.26%
2023 1 2.24%
2023 2 2.33%
2023 3 2.30%
2023 4 2.27%
2023 5 2.21%
2023 6 2.20%
2023 7 2.30%
2023 8 2.34%
2023 9 2.34%
2023 10 2.39%
2023 11 2.30%
2023 12 2.18%
2024 1 2.27%
2024 2 2.28%
2024 3 2.31%
2024 4 2.39%
2024 5 2.33%

Conditional Color with limits, whole row

monthly_FRED |> 
  gt() |>
  data_color(
    columns = Avg_Inf,
    rows = Avg_Inf < 2.00,
    method = "numeric",
    target_columns = everything(),
    palette = c("green", "red")) |>
  fmt_percent(columns = Avg_Inf, scale_values = FALSE)

Year Month Avg_Inf
2019 5 1.75%
2019 6 1.70%
2019 7 1.75%
2019 8 1.59%
2019 9 1.59%
2019 10 1.56%
2019 11 1.64%
2019 12 1.72%
2020 1 1.72%
2020 2 1.62%
2020 3 0.99%
2020 4 1.10%
2020 5 1.12%
2020 6 1.27%
2020 7 1.46%
2020 8 1.66%
2020 9 1.66%
2020 10 1.70%
2020 11 1.71%
2020 12 1.92%
2021 1 2.08%
2021 2 2.18%
2021 3 2.28%
2021 4 2.35%
2021 5 2.47%
2021 6 2.34%
2021 7 2.33%
2021 8 2.35%
2021 9 2.34%
2021 10 2.54%
2021 11 2.62%
2021 12 2.46%
2022 1 2.45%
2022 2 2.46%
2022 3 2.85%
2022 4 2.88%
2022 5 2.69%
2022 6 2.62%
2022 7 2.36%
2022 8 2.51%
2022 9 2.38%
2022 10 2.39%
2022 11 2.37%
2022 12 2.26%
2023 1 2.24%
2023 2 2.33%
2023 3 2.30%
2023 4 2.27%
2023 5 2.21%
2023 6 2.20%
2023 7 2.30%
2023 8 2.34%
2023 9 2.34%
2023 10 2.39%
2023 11 2.30%
2023 12 2.18%
2024 1 2.27%
2024 2 2.28%
2024 3 2.31%
2024 4 2.39%
2024 5 2.33%

Application: Correlation Matrix

cor_ex <- cor(swiss) |> round(2) |> as.data.frame.matrix()
cor_ex$varname <- row.names(cor_ex)
row.names(cor_ex) <- 1:6
cor_ex   |>
  gt(rowname_col = "varname") |>
  data_color(
    direction = "row",
    palette = "YlOrRd",
    na_color = "white"
  ) 

Fertility Agriculture Examination Education Catholic Infant.Mortality
Fertility 1.00 0.35 -0.65 -0.66 0.46 0.42
Agriculture 0.35 1.00 -0.69 -0.64 0.40 -0.06
Examination -0.65 -0.69 1.00 0.70 -0.57 -0.11
Education -0.66 -0.64 0.70 1.00 -0.15 -0.10
Catholic 0.46 0.40 -0.57 -0.15 1.00 0.18
Infant.Mortality 0.42 -0.06 -0.11 -0.10 0.18 1.00

Mini graphs in gt

Built in data from their documentation:

gt(illness)
test units day_3 day_4 day_5 day_6 day_7 day_8 day_9 norm_l norm_u
Viral load copies per mL 12000.000 4200.000 1600.000 830.000 760.000 520.000 250.000 NA NA
WBC x10^9 / L 5.260 4.260 9.920 10.490 24.770 30.260 19.030 4.00 10.000
Neutrophils x10^9 / L 4.870 4.720 7.920 18.210 22.080 27.170 16.590 2.00 8.000
RBC x10^12 / L 5.720 5.980 4.230 4.830 4.120 2.680 3.320 4.00 5.500
Hb g / L 153.000 135.000 126.000 115.000 75.000 87.000 95.000 120.00 160.000
PLT x10^9 / L 67.000 38.600 27.400 26.200 74.100 36.200 25.600 100.00 300.000
ALT U/L 12835.000 12632.000 6426.700 4263.100 1623.700 672.600 512.400 9.00 50.000
AST U/L 23672.000 21368.000 14730.000 8691.000 2189.000 1145.000 782.500 15.00 40.000
TBIL umol/L 117.200 143.800 137.200 158.100 127.300 105.100 163.200 0.00 18.800
DBIL umol/L 71.400 104.600 94.600 143.900 117.800 83.600 126.300 0.00 6.800
NH3 mmol/L 115.200 135.200 131.000 176.700 84.200 72.400 91.900 10.00 47.000
PT s 24.600 42.400 53.700 54.000 22.600 16.800 29.500 9.40 12.500
APTT s 39.200 57.200 65.900 68.300 62.400 61.700 114.700 25.10 36.500
PTA % 41.000 25.000 19.000 14.000 51.000 55.000 31.000 70.00 130.000
DD mg / L 32.900 35.100 24.500 25.600 18.700 24.700 64.800 0.00 5.000
FDP ug / mL 84.700 92.500 77.200 NA NA 157.200 291.700 0.00 5.000
Fibrinogen mg / dL 238.100 216.800 135.000 85.200 105.700 NA 64.300 200.00 400.000
LDH U/L 5727.300 2622.800 2418.700 546.300 NA 637.200 NA 80.00 285.000
HBDH NA 5971.200 5826.900 4826.900 2871.200 NA 1163.600 NA 74.00 182.000
CK U/L 725.000 792.100 760.200 1263.600 NA 1294.200 NA 38.00 174.000
CKMB U/L 75.000 71.000 58.000 65.000 NA 68.000 NA NA 25.000
BNP pg / mL 37.000 NA 73.000 NA 482.000 421.000 1332.000 NA 100.000
MYO ng / mL 636.600 762.100 364.600 9999.000 9999.000 9999.000 9999.000 0.00 140.000
TnI ng / mL 0.026 0.041 0.046 0.164 0.141 2.839 8.937 0.00 0.028
CREA umol / L 705.600 683.600 523.600 374.000 259.600 241.800 211.400 59.00 104.000
BUN mmol / L 20.130 25.330 13.330 7.840 4.230 3.920 3.410 1.70 8.300
AMY U / L NA 232.800 394.600 513.700 NA 642.900 538.900 0.00 115.000
LPS U / L NA 227.600 526.900 487.900 NA 437.800 414.500 5.60 51.300
K mmol / L 4.190 4.640 4.340 4.830 4.530 4.370 5.740 3.50 5.300
Na mmol / L 136.300 135.700 142.100 140.800 144.800 143.600 144.200 137.00 147.000
Cl mmol / L 91.200 92.900 96.600 99.200 102.100 99.500 105.200 99.00 110.000
Ca mmol / L 1.740 1.640 2.250 2.350 2.160 2.030 2.290 2.20 2.550
P mmol / L 2.960 3.230 1.470 1.150 0.970 1.570 1.630 0.81 1.450
Lac mmol / L 2.320 2.420 2.190 2.660 NA 6.150 5.460 1.33 1.780
CRP mg / L 43.600 38.600 28.600 21.500 NA 4.300 6.400 0.00 5.000
PCT ng / mL 0.570 NA 1.350 2.260 1.790 3.480 5.920 NA 0.050
IL-6 NA NA NA 165.900 58.300 74.600 737.200 NA NA 7.000
CD3+CD4+ T cells per uL NA 174.000 153.000 184.000 243.000 370.000 252.000 706.00 1125.000
CD3+CD8+ T cells per uL NA 142.000 135.000 126.000 132.000 511.000 410.000 323.00 836.000

Application: nano graphs

illness |>
  dplyr::slice_head(n = 10) |>
  gt(rowname_col = "test") |>
  tab_header("Partial summary of daily tests performed on YF patient") |>
  tab_stubhead(label = md("**Test**")) |>
  cols_hide(columns = starts_with("norm")) |>
  fmt_units(columns = units) |>
  cols_nanoplot(
    columns = starts_with("day"),
    new_col_name = "nanoplots",
    new_col_label = md("*Progression*")
  ) |>
  cols_align(align = "center", columns = nanoplots) |>
  cols_merge(columns = c(test, units), pattern = "{1} ({2})") |>
  tab_footnote(
    footnote = "Measurements from Day 3 through to Day 8.",
    locations = cells_column_labels(columns = nanoplots)
  )

Partial summary of daily tests performed on YF patient
Test Progression1
Viral load (copies per mL)
12.0K 250 12.0K 4.20K 1.60K 830 760 520 250
WBC (×109/L)
30.3 4.26 5.26 4.26 9.92 10.5 24.8 30.3 19.0
Neutrophils (×109/L)
27.2 4.72 4.87 4.72 7.92 18.2 22.1 27.2 16.6
RBC (×1012/L)
5.98 2.68 5.72 5.98 4.23 4.83 4.12 2.68 3.32
Hb (g/L)
153 75 153 135 126 115 75 87 95
PLT (×109/L)
74.1 25.6 67.0 38.6 27.4 26.2 74.1 36.2 25.6
ALT (U/L)
12.8K 512 12.8K 12.6K 6.43K 4.26K 1.62K 673 512
AST (U/L)
23.7K 782 23.7K 21.4K 14.7K 8.69K 2.19K 1.14K 782
TBIL (µmol/L)
163 105 117 144 137 158 127 105 163
DBIL (µmol/L)
144 71.4 71.4 105 94.6 144 118 83.6 126
1 Measurements from Day 3 through to Day 8.

Extension: library(gtsummary)

This is experimental, but it makes presenting model results convenient.

binaryEX <- read_csv("https://raw.githubusercontent.com/lewv/S24STATS101A/main/data/binaryEX.csv")
binaryEX$rank <- as.factor(binaryEX$rank)

mod1 <- glm(admit ~ gre + gpa , data = binaryEX, family = binomial)
mod2 <- glm(admit ~ gre + gpa + rank, data = binaryEX, family = binomial)

t1 <- tbl_regression(mod1, exponentiate = TRUE, digits =5)
t2 <- tbl_regression(mod2, exponentiate = TRUE, digits =5)

tbl_merge(
    tbls = list(t1, t2),
    tab_spanner = c("**Model 1**", "**Model 2**")
  )

Characteristic Model 1 Model 2
OR1 95% CI1 p-value OR1 95% CI1 p-value
gre 1.00 1.00, 1.00 0.011 1.00 1.00, 1.00 0.038
gpa 2.13 1.14, 4.02 0.018 2.23 1.17, 4.32 0.015
rank





    1



    2


0.51 0.27, 0.94 0.033
    3


0.26 0.13, 0.51 <0.001
    4


0.21 0.09, 0.47 <0.001
1 OR = Odds Ratio, CI = Confidence Interval

Reactable

Reactable example - Basic

Interactive data tables for R, based on the React Table library and made with reactR. This table is paginated and sortable by default.

  • Grouping and aggregation
  • Built-in column formatting
  • Custom rendering via R or JavaScript — use Shiny HTML tags and HTML widgets in tables
  • Expandable rows and nested tables
  • Conditional styling
  • Works seamlessly within R Markdown documents and Shiny apps
reactable(NVIDIA)

Reactable example with formatting

reactable(NVIDIA, columns = list(
  Date = colDef(
    format = colFormat(date = TRUE)
  ),
  Open = colDef(
    format = colFormat(currency = "USD", separators = TRUE, locales = "en-US")
  ),
  High = colDef(
    format = colFormat(currency = "USD", separators = TRUE, locales = "en-US")
  ),
  Low = colDef(
    format = colFormat(currency = "USD", separators = TRUE, locales = "en-US")
  ),
  Close = colDef(
    format = colFormat(currency = "USD", separators = TRUE, locales = "en-US")
  ),
  `Adj Close` = colDef(
    format = colFormat(currency = "USD", separators = TRUE, locales = "en-US")
  ), 
 Volume = colDef(
    format = colFormat(separators = TRUE, locales = "en-US")
  )
))

Downloadable Reactable example with formatting

library(htmltools)

htmltools::browsable(tagList(
  tags$button("Download as CSV", onclick = "Reactable.downloadDataCSV('nvda-table')"),
  
  reactable(
    NVIDIA,
    elementId = "nvda-table",
    columns = list(
      Date = colDef(format = colFormat(date = TRUE)),
      Open = colDef(format = colFormat(
        currency = "USD",
        separators = TRUE,
        locales = "en-US"
      )),
      High = colDef(format = colFormat(
        currency = "USD",
        separators = TRUE,
        locales = "en-US"
      )),
      Low = colDef(format = colFormat(
        currency = "USD",
        separators = TRUE,
        locales = "en-US"
      )),
      Close = colDef(format = colFormat(
        currency = "USD",
        separators = TRUE,
        locales = "en-US"
      )),
      `Adj Close` = colDef(format = colFormat(
        currency = "USD",
        separators = TRUE,
        locales = "en-US"
      )),
      Volume = colDef(format = colFormat(
        separators = TRUE, locales = "en-US"
      ))
    )
  )
))

More about Reactable

Reactable

Shiny App

Visualizing Time

Time is Everywhere

  • And for good reason

  • A great discussion of visualizing time can be found in “Visualize This!” by Nathan Yau.

  • What follow are some updated graphs based on his Chapter on visualizing time.

Discrete Time Points

Might consider bar, here is change over time

fredjobs <- read_csv("https://raw.githubusercontent.com/lewv/S24STATS101A/main/data/fredjobs.csv", 
     col_types = cols(DATE = col_date(format = "%Y-%m-%d")))

jobs_data <- fredjobs %>%
  arrange(DATE) %>%  #
  mutate(NetChange = JTSJOL - lag(JTSJOL))

gt(jobs_data)
DATE JTSJOL NetChange
2016-11-01 5971 NA
2016-12-01 5964 -7
2017-01-01 5617 -347
2017-02-01 5923 306
2017-03-01 5811 -112
2017-04-01 6091 280
2017-05-01 5826 -265
2017-06-01 6305 479
2017-07-01 6238 -67
2017-08-01 6276 38
2017-09-01 6320 44
2017-10-01 6408 88
2017-11-01 6271 -137
2017-12-01 6336 65
2018-01-01 6621 285
2018-02-01 6552 -69
2018-03-01 6818 266
2018-04-01 6877 59
2018-05-01 7016 139
2018-06-01 7230 214
2018-07-01 7190 -40
2018-08-01 7208 18
2018-09-01 7411 203
2018-10-01 7304 -107
2018-11-01 7594 290
2018-12-01 7489 -105
2019-01-01 7502 13
2019-02-01 7066 -436
2019-03-01 7317 251
2019-04-01 7272 -45
2019-05-01 7275 3
2019-06-01 7194 -81
2019-07-01 7042 -152
2019-08-01 7178 136
2019-09-01 7124 -54
2019-10-01 7289 165
2019-11-01 6888 -401
2019-12-01 6699 -189
2020-01-01 7170 471
2020-02-01 6974 -196
2020-03-01 5924 -1050
2020-04-01 4637 -1287
2020-05-01 5593 956
2020-06-01 6156 563
2020-07-01 6491 335
2020-08-01 6369 -122
2020-09-01 6505 136
2020-10-01 6838 333
2020-11-01 6857 19
2020-12-01 6758 -99
2021-01-01 7185 427
2021-02-01 7818 633
2021-03-01 8519 701
2021-04-01 9282 763
2021-05-01 9905 623
2021-06-01 10317 412
2021-07-01 10991 674
2021-08-01 10884 -107
2021-09-01 10875 -9
2021-10-01 11365 490
2021-11-01 11178 -187
2021-12-01 11511 333
2022-01-01 11243 -268
2022-02-01 11700 457
2022-03-01 12182 482
2022-04-01 11773 -409
2022-05-01 11473 -300
2022-06-01 11204 -269
2022-07-01 11537 333
2022-08-01 10119 -1418
2022-09-01 10784 665
2022-10-01 10526 -258
2022-11-01 10702 176
2022-12-01 11000 298
2023-01-01 10425 -575
2023-02-01 9849 -576
2023-03-01 9623 -226
2023-04-01 9904 281
2023-05-01 9311 -593
2023-06-01 9125 -186
2023-07-01 8805 -320
2023-08-01 9358 553
2023-09-01 9307 -51
2023-10-01 8685 -622
2023-11-01 8931 246
2023-12-01 8889 -42
2024-01-01 8748 -141
2024-02-01 8813 65
2024-03-01 8488 -325

Discrete Time Points

Jobs data is summarized for us by US government and are arguably discrete measurements. A bar chart (not histogram) is most appropriate

# barplot
ggplot(jobs_data[-1,], aes(x = DATE, y = NetChange, fill = NetChange > 0)) +
  geom_bar(stat = "identity") +
  geom_vline(xintercept = as.Date("2021-01-01"), size =1) +
  labs(title = "Net Change in US Jobs Over Time",
       x = "Date",
       y = "Net Change in Jobs") +
  theme_minimal() +
  theme(legend.position = "none")

Hot Dog Data (modified Yau’s original)

hotdogs <- read_csv("https://raw.githubusercontent.com/lewv/S24STATS101A/main/data/hotdogs.csv")
gt(hotdogs)
Year Winner Dogs eaten Country New record
1980 Paul Siederman & Joe Baldini 9.10 United States 0
1981 Thomas DeBerry 11.00 United States 0
1982 Steven Abrams 11.00 United States 0
1983 Luis Llamas 19.50 Mexico 0
1984 Birgit Felden 9.50 Germany 0
1985 Oscar Rodriguez 11.75 United States 0
1986 Mark Heller 15.50 United States 0
1987 Don Wolfman 12.00 United States 0
1988 Jay Green 14.00 United States 0
1989 Jay Green 13.00 United States 0
1990 Mike DeVito 16.00 United States 0
1991 Frank Dellarosa 21.50 United States 1
1992 Frank Dellarosa 19.00 United States 0
1993 Mike DeVito 17.00 United States 0
1994 Mike DeVito 20.00 United States 0
1995 Edward Krachie 19.50 United States 0
1996 Edward Krachie 22.25 United States 1
1997 Hirofumi Nakajima 24.50 Japan 1
1998 Hirofumi Nakajima 19.00 Japan 0
1999 Steve Keiner 20.25 United States 0
2000 Kazutoyo "The Rabbit" Arai 25.13 Japan 1
2001 Takeru Kobayashi 50.00 Japan 1
2002 Takeru Kobayashi 50.50 Japan 1
2003 Takeru Kobayashi 44.50 Japan 0
2004 Takeru Kobayashi 53.50 Japan 1
2005 Takeru Kobayashi 49.00 Japan 0
2006 Takeru "Tsunami" Kobayashi 53.75 Japan 1
2007 Joey Chestnut 66.00 United States 1
2008 Joey Chestnut 59.00 United States 0
2009 Joey Chestnut 68.00 United States 1
2010 Joey Chestnut 54.00 United States 0
2011 Joey Chestnut 62.00 United States 0
2012 Joey Chestnut 68.00 United States 0
2013 Joey Chestnut 69.00 United States 1
2014 Joey Chestnut 61.00 United States 0
2015 Matthew Stonie 62.00 United States 0
2016 Joey Chestnut 70.00 United States 1
2017 Joey Chestnut 72.00 United States 1
2018 Joey Chestnut 74.00 United States 1
2019 Joey Chestnut 71.00 United States 0
2020 Joey Chestnut 75.00 United States 1
2021 Joey Chestnut 76.00 United States 1
2022 Joey Chestnut 63.00 United States 0
2023 Joey Chestnut 62.00 United States 0

Histogram-like barplot

# barplot
ggplot(hotdogs, aes(x = Year, y = `Dogs eaten`, fill = Country == "United States")) +
  geom_bar(stat = "identity") +
  scale_fill_manual(values = c("gray", "blue"), labels = c("Non-US", "US")) +
  labs(title = "Hot Dog Eating Contest Results",
       x = "Date",
       y = "Hot Dogs Eaten") +
  theme_minimal() +
  theme(legend.position = "none")

Stacked barplot over time

Using a different dataset, this needs to be fixed a little bit, right now it is “wide format”

adv_deg <- read_csv("https://raw.githubusercontent.com/lewv/S24STATS101A/main/data/adv_deg.csv")
gt(adv_deg)
YEAR MS_PCT Prof_PCT PhD_PCT MS Prof PhD
2015 8.7 1.6 1.7 18471 3365 3609
2016 9.3 1.5 1.8 19958 3178 3986
2017 9.5 1.5 1.9 20592 3172 4077
2018 9.6 1.4 2.0 21048 3172 4468
2019 10.0 1.4 2.0 22214 3136 4529
2020 10.5 1.5 2.1 23516 3362 4659
2021 10.7 1.5 2.1 24059 3443 4730
2022 10.6 1.5 2.1 23881 3444 4848

Pivot to long (stacked data)

YEAR Degree Pct
2015 MS_PCT 8.7
2015 Prof_PCT 1.6
2015 PhD_PCT 1.7
2016 MS_PCT 9.3
2016 Prof_PCT 1.5
2016 PhD_PCT 1.8
2017 MS_PCT 9.5
2017 Prof_PCT 1.5
2017 PhD_PCT 1.9
2018 MS_PCT 9.6
2018 Prof_PCT 1.4
2018 PhD_PCT 2.0
2019 MS_PCT 10.0
2019 Prof_PCT 1.4
2019 PhD_PCT 2.0
2020 MS_PCT 10.5
2020 Prof_PCT 1.5
2020 PhD_PCT 2.1
2021 MS_PCT 10.7
2021 Prof_PCT 1.5
2021 PhD_PCT 2.1
2022 MS_PCT 10.6
2022 Prof_PCT 1.5
2022 PhD_PCT 2.1

Stacked Barplot

But a line plot may look better (probably a personal preference), should try to compare

# barplot
ggplot(degree_long, aes(x = YEAR, y = Pct, fill = Degree)) +
  geom_bar(stat = "identity") +
  labs(title = "Advanced Degrees 2015-2022 USA Age 25+",
       x = "Year",
       y = "Percent",
       fill = "Degree") +
  theme_classic()

Point + Line plot

ggplot makes it easy because we only need to swap out the geoms_

ggplot(degree_long, aes(x = YEAR, y = Pct, color = Degree)) +
  geom_point() +
  geom_line() +
  labs(title = "Advanced Degrees 2015-2022 USA Age 25+",
       x = "Year",
       y = "Percent",
       color = "Degree Type") +
  theme_classic()

Step plot

To demonstrate the discontinuous nature of price changes, a step plot might be useful

postage <- read_csv("https://raw.githubusercontent.com/lewv/S24STATS101A/main/data/postage.csv", col_types = cols(Date = col_date(format = "%B %d, %Y")))

postage <- postage %>% filter(Date > as.Date("1970-01-01"))
  
ggplot(postage, aes(x = Date, y = Cents)) +
  geom_step() +
  labs(title = "Postage Rate Changes since 1/1970",
       x = "Date",
       y = "Postage Rate") +
  theme_classic()

Step plot + points

adding points to highlight the rapidity of price changes

ggplot(postage, aes(x = Date, y = Cents)) +
  geom_step() +
  geom_point(color = "red") +
  labs(title = "Postage Rate Changes since 1/1970",
       x = "Date",
       y = "Postage Rate") +
  theme_classic()

Line plot

Just to compare

ggplot(postage, aes(x = Date, y = Cents)) +
  geom_line() +
  labs(title = "Postage Rate Changes since 1/1970",
       x = "Date",
       y = "Postage Rate") +
  theme_classic()

Smoothing

Sometimes, a line might be misleading. Jobs data is volatile and discontinuous

ggplot(fredjobs, aes(x = DATE, y = JTSJOL)) +
  geom_line() +
  labs(
       title = "Job Creation since 2017",
       x = "Date",
       y = "Number of Jobs Created (in 000s) " 
  ) +
  theme_classic()

Smoothing

Default method is NULL so loess is used when there are less than 1000 observations. R tell us what it is using.

ggplot(fredjobs, aes(x = DATE, y = JTSJOL)) +
  geom_line() +
  geom_smooth() +
  labs(
       title = "Job Creation since 2017",
       x = "Date",
       y = "Number of Jobs Created (in 000s) " 
  ) +
  theme_classic()

Smoothing - adjust span

span adjusts the faction of points used to fit each local regression, smaller values have more “wiggle”

ggplot(fredjobs, aes(x = DATE, y = JTSJOL)) +
  geom_line() +
  geom_smooth(span = 0.2) +
  labs(
       title = "Job Creation since 2017",
       x = "Date",
       y = "Number of Jobs Created (in 000s) " 
  ) +
  theme_classic()

Smoothing - adjust span

span adjusts the faction of points used to fit each local regression

ggplot(fredjobs, aes(x = DATE, y = JTSJOL)) +
  geom_line() +
  geom_smooth(span = 0.8) +
  labs(
       title = "Job Creation since 2017",
       x = "Date",
       y = "Number of Jobs Created (in 000s) " 
  ) +
  theme_classic()

Smoothing (lm)

A straight line doesn’t really work, too heavy-handed in its “smoothing”

ggplot(fredjobs, aes(x = DATE, y = JTSJOL)) +
  geom_line() +
  geom_smooth(method = "lm") +
  labs(
       title = "Job Creation since 2017",
       x = "Date",
       y = "Number of Jobs Created (in 000s) " 
  ) +
  theme_classic()

Smoothing other methods

You can add “knots” to capture the variation you seek.

ggplot(fredjobs, aes(x = DATE, y = JTSJOL)) +
  geom_line() +
  geom_smooth(method = "gam", formula = y ~ s(x, k = 20)) + 
  labs(
       title = "Job Creation since 2017",
       x = "Date",
       y = "Number of Jobs Created (in 000s) " 
  ) +
  theme_classic()